0
0

More than 3 years have passed since last update.

【VSCode】clang-formatで自動 format

Posted at

背景

以前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される

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0