I'm using the C++ Extension for VSCode (Visual Studio Code).
Currently, I have the setting "C_Cpp.clang_format_formatOnSave"
set to true
.
This format's my code when I save my C++ file. But the format results in curly braces on new lines rather than on the same line.
Current C++ VSCode Formatted
for (int i = 0; i < 10; i++)
{
// ...
}
What I Want C++ VSCode Formatted Code to Look Like
for (int i = 0; i < 10; i++) {
// ...
}
I also have editor.wrappingIndent
set to "same"
.
How can I make curly braces in C++ format on the same line in Visual Studio Code?
"{ BasedOnStyle: Google, IndentWidth: 4 }"
e.g.
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}"
ColumnLimit: 0
is helpful too, because google limit will break your code to next line when you do not need it.If you want more:
More detail:
English: https://medium.com/@zamhuang/vscode-how-to-customize-c-s-coding-style-in-vscode-ad16d87e93bf