Visual Code C/C++ 大括号格式 {}
Visual Code C/C++ formatting of braces {}
在 VSCode 中,我希望左大括号 {
位于同一行,而不是换行,为此我将 C_Cpp.clang_format_fallbackStyle
从 Visual Studio 到 LLVM,这似乎有效。
但它做了我不想要的事情,它格式化了我的 if-else 语句,如下所示:
if (condition){
do_something()
} else {
do_something_else()
}
相反,我希望它是这样的:
if (condition){
do_something()
}
else {
do_something_else()
}
基本上我希望每个右括号都在线,无论是用于 if-else 语句还是 try-catch 或其他。
我该怎么做?
在你的 VS Code 设置中应该可以做类似
的事情
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, BreakBeforeBraces: Custom, BraceWrapping: { BeforeElse: true }"
更多信息:
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
https://code.visualstudio.com/docs/cpp/cpp-ide
在 VSCode 中,我希望左大括号 {
位于同一行,而不是换行,为此我将 C_Cpp.clang_format_fallbackStyle
从 Visual Studio 到 LLVM,这似乎有效。
但它做了我不想要的事情,它格式化了我的 if-else 语句,如下所示:
if (condition){
do_something()
} else {
do_something_else()
}
相反,我希望它是这样的:
if (condition){
do_something()
}
else {
do_something_else()
}
基本上我希望每个右括号都在线,无论是用于 if-else 语句还是 try-catch 或其他。 我该怎么做?
在你的 VS Code 设置中应该可以做类似
的事情
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, BreakBeforeBraces: Custom, BraceWrapping: { BeforeElse: true }"
更多信息:
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
https://code.visualstudio.com/docs/cpp/cpp-ide