Reputation: 53
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?
Upvotes: 1
Views: 1040
Reputation: 340
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
Upvotes: 2