1. 安装clang-format
2. 配置settings.json
{
"files.associations": {
"*.idl": "idl",
"condition_variable": "cpp"
},
//主要是下面配置项
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"clang-format.fallbackStyle": "Google",
"clang-format.language.c.style": "Google",
"clang-format.executable": "clang-format",
"clang-format.language.cpp.style": "Google",
"C_Cpp.autocompleteAddParentheses": true,
"[proto3]": {
"editor.defaultFormatter": "zxh404.vscode-proto3"
}
}
3. ubuntu也可命令下载:
sudo apt install clang-format