Search code examples
c++cvisual-studio-codeformatter

How to prevent to break line in C at the end of for loop before ;


Actually my options are : "C_Cpp.clang_format_fallbackStyle": "{ BreakBeforeBraces: Linux, IndentWidth: 4, ColumnLimit: 80, UseTab: Never, SortIncludes: false, AlignAfterOpenBracket: DontAlign }"

I have:

for (int i = 0; i < 5; i++)
    ;

I want:

for (int i = 0; i < 5; i++);

Solution

  • This is a known issue and it make a warning. The only way is to write this:

    for (int i = 0; i < 5; i++) {}