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

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐