首先安装 clang-format。
由于本人使用 Ubuntu,故直接在终端中输入:
sudo apt install clang-format并在 vscode 中直接搜索安装 clang-format 插件。
打开 vscode 设置的 .json 文件,添加以下一行:
"clang-format.style": "{BasedOnStyle: Google, IndentWidth: 4, AccessModifierOffset: -4, SortIncludes: false, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 110, Cpp11BracedListStyle: false }"配置完成。