背景
以前formatしないでcodingしてたら、怒られました(笑)
VSCodeにはsave時にformatする機能があると教えてもらって、とても便利だったのでメモメモ
環境
ubuntu18
vscode
C++
インストール & 設定
1 clang formatをinstallする
apt install clang-format-6.0
2 vscodeのextensionでclang-formatをinsatllする
3 setting.jsonを設定する
gedit ~/.config/Code/User/settings.json
{
"editor.formatOnSave": true,
"editor.formatOnType": true,
"clang-format.executable": "/usr/bin/clang-format-6.0",
"C_Cpp.updateChannel": "Insiders",
"workbench.editor.enablePreview": false,
"window.zoomLevel": -1,
"[cpp]": {
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"cmake.configureOnOpen": true,
}
5 codeをsave(ctrl+s)するたびformatされる