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

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐