背景
习惯使用非严格意义上的Google C++ Style,但是VS Code插件C/C++
支持的clang-format
中的Google C++ Style缩进是2,因此感受很不好。
解决办法
打开VS Code的设置,搜索Clang_format_fallback Style
,添加下面这段话:
{ BasedOnStyle: Google, IndentWidth: 4, TabWidth: 4, ColumnLimit: 110, AccessModifierOffset: -4, AllowShortIfStatementsOnASingleLine: true, AllowShortLoopsOnASingleLine: true, AllowShortBlocksOnASingleLine: true, AllowShortCaseLabelsOnASingleLine: true }
最终效果大致为: