rad*_*ler 34 c++ ubuntu lint visual-studio-code
我在ubuntu上.当我在VS Code中编写C++代码时,它会自动发送类似的内容
if (condition == true)
{
DoStuff();
}
Run Code Online (Sandbox Code Playgroud)
相反,我想做
if (condition == true) {
DoStuff();
}
Run Code Online (Sandbox Code Playgroud)
我怎么做?我已经从市场上安装了C/C++扩展.
Zam*_*Zam 42
基于@Chris Drew的回答
"{ BasedOnStyle: Google, IndentWidth: 4 }"例如
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}"
ColumnLimit: 0也很有帮助,因为谷歌限制会在你不需要的时候将你的代码破坏到下一行.如果你想要更多:
Chr*_*rew 33
C_Cpp.clang_format_fallbackStyleC_Cpp.clang_format_fallbackStyle,C_Cpp.clang_format_fallbackStylevk-*_*ode 12
我通常有自己的格式化几乎所有内容的方式:) 所以我更喜欢最灵活的方式来实现这一点。就 C++ 格式而言,VS 代码是迄今为止最灵活的编辑器,而且“简单”。
这是您应该执行的操作以获得自定义格式。
这是我的文件供您参考。
Standard: Cpp11
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 0
AccessModifierOffset: -4
NamespaceIndentation: All
BreakBeforeBraces: Custom
BraceWrapping:
AfterEnum: true
AfterStruct: true
AfterClass: true
SplitEmptyFunction: true
AfterControlStatement: false
AfterNamespace: false
AfterFunction: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
SplitEmptyRecord: true
SplitEmptyNamespace: true
Run Code Online (Sandbox Code Playgroud)
您特别感兴趣的格式是“AfterControlStatement: false”