Warm tip: This article is reproduced from serverfault.com, please click

Break after control statements in clang-format

发布于 2015-10-02 12:28:36

I'm using BreakBeforeBraces: Allman in my .clang-format file, but braces in control statements (such as if, for, while, ...) are not being put on their own line.

// Currently:
void foo()
{
    while(true) {
        bar();
    }
}

// What I want:
void foo()
{
    while(true) 
    {
        bar();
    }
}

I've read that you can set nested configuration classes for braces in BraceWrapping, but I could't figure out the correct YAML syntax (and JSON syntax for the sublime text plugin), and couldn't find any existing example.

Is there any way of doing this?

Questioner
Vittorio Romeo
Viewed
11
Vittorio Romeo 2016-01-07 08:39:31

Achieving the desired result with a specific combination of style options is impossible at the moment. I've reported the issue as bug 25069.