应用clang-format对c++代码时进行格式化

1. VS Code

settings.json文件

{
  
  // "C_Cpp.clang_format_fallbackStyle": "Google",
  "C_Cpp.clang_format_path": "D:/GreenSoftware/CPlusPlus/ClangLLVM/bin/clang-format.exe",
  "C_Cpp.clang_format_style": "file:D:/GreenSoftware/CPlusPlus/ClangLLVM/format-styles/.clang-format-microsoft",
  "clangd.enableCodeCompletion": false,

......
}


2. Qt Creator

帮助 –》 关于插件

image

重启Qt Creator

image


将.clang-format-microsoft重命名为.clang-format,放在.pro或.sln同目录下

posted @ 2025-04-22 22:46  ParamousGIS  阅读(31)  评论(0)    收藏  举报