参考资料:
[1]VSCode 添加clang-format扩展
[2]团队效率工具: 代码格式化之Clang-format
操作:
-
VScode中安装Clang-Format插件
image.png - 安装 clang-format(因为插件中需要填写可执行文件地址)
sudo apt-get install clang-format
-
打开File->Preference->Settings,点击右上角,打开settings.json
image.png
linux类似这样:
{
"clang-format.executable": "/usr/lib/llvm-3.8/bin/clang-format",
//鼠标滑动改变字体大小
"editor.mouseWheelZoom": true,
//改变左侧界面字体
"window.zoomLevel": 1.5,
"editor.fontSize": 18,
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"editor.formatOnSave": true,
"clang-format.style": "Google",
"extensions.ignoreRecommendations": true
//改变编辑器字体大小
//"editor.fontSize": 15,
}
win类似这样:
{
"editor.fontSize": 25,
"window.zoomLevel": 0,
"leetcode.endpoint": "leetcode-cn",
"leetcode.workspaceFolder": "C:\\Users\\optimization\\.leetcode",
"todo-tree.tree.showScanModeButton": false,
"clang-format.executable": "C:\\Users\\optimization\\.vscode-insiders\\extensions\\ms-vscode.cpptools-0.28.3\\LLVM\\bin\\clang-format.exe",
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format",
},
"editor.formatOnSave": true,
"clang-format.style": "Google"
}
网友评论