Keltek
Keltek

Reputation: 660

Clang-Format: Open brace on newline after multiline statement

I'm looking for a way to conditionally set the opening brace on a newline only after the statement that preceded it spanned multiple lines.

For example

void foo() {  // single line
}

void bar(int aaaaaaaaaaaaaaaaaaaa
         int bbbbbbbbbbbbbbbbbbbb)
{  // declaration of bar spanned multiple lines, brace on newline.
}

for (int i = 0;
     i < 10; ++i)
{  // for loop spanned multiple lines, so brace on newline.
}

Is there any rule that allows this in clang format? I can't seem to find one.

Upvotes: 4

Views: 418

Answers (1)

Romain Laneuville
Romain Laneuville

Reputation: 497

.clang-format

BraceWrapping:
  AfterControlStatement: MultiLine

Feature proposal and merged

Upvotes: 1

Related Questions