1

In VSCode, I wanted my opening curly braces { to be in the same line, instead of a new line and for that I changed C_Cpp.clang_format_fallbackStyle from Visual Studio to LLVM, which seemed to work.

But it does this thing which I don't want, which is it formats my if-else statements like this:

if (condition){
    do_something()
} else {
    do_something_else()
}

Instead, I want it to be like this:

if (condition){
    do_something()
} 
else {
    do_something_else()
}

Basically I want each closing bracket to be on it's on line, whether it's for if-else statements or try-catch, or whatever. How do I do that?

Aaron Record
  • 330
  • 4
  • 13
Satvik Gupta
  • 53
  • 1
  • 2
  • 7

1 Answers1

2

In your VS Code settings should be able to do something like
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, BreakBeforeBraces: Custom, BraceWrapping: { BeforeElse: true }"

For more info:
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Visual Studio Code formatting for "{ }"
https://code.visualstudio.com/docs/cpp/cpp-ide

Aaron Record
  • 330
  • 4
  • 13