[英]How do I set up VSCode to NOT put curly braces on a new line?
Basically the opposite of this question: 基本上与这个问题相反:
How do I set up VSCode to put curly braces on a new line? 如何设置VSCode以将花括号放在新行上?
I am working with the PlatformIO extension for VSCode and whenever I format the document, I get all my curly braces misplaced on new lines, which looks horrible (coming from Java). 我正在使用VSIO的PlatformIO扩展,每当我格式化文档时,我的所有花括号都放在新行上,这看起来很糟糕(来自Java)。
Similar question here , but it is asking about a specific C++ extension. 类似的问题在这里 ,但它询问特定的C ++扩展。
You can add a .clangformat
file to your project. 您可以将
.clangformat
文件添加到项目中。 For example: 例如:
---
BasedOnStyle: Google
UseTab: Never
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Attach
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AccessModifierOffset: -4
ColumnLimit: 88
...
You can read about the options here: https://clang.llvm.org/docs/ClangFormatStyleOptions.html 您可以在这里阅读有关选项: https : //clang.llvm.org/docs/ClangFormatStyleOptions.html
Alternatively you can edit your vscode settings fallback style: 或者,您可以编辑vscode设置后备样式:
{
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, TabWidth: 4}"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.