Vittorio Romeo
Vittorio Romeo

Reputation: 93384

Break after control statements in clang-format

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?

Upvotes: 5

Views: 3925

Answers (2)

Barijaona
Barijaona

Reputation: 11

To work around this, I first run artistic style with the option -A10, before running clang-format

Upvotes: 0

Vittorio Romeo
Vittorio Romeo

Reputation: 93384

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

Upvotes: 5

Related Questions