LoginSignup
99
74

More than 3 years have passed since last update.

【VSCode】言語ごとにインデント幅、タブとスペースどちらを使うか設定する

Posted at

動作確認環境

  • Windows 10 Version 1903
  • Visual Studio Code 1.37.1

参考文献

[VisualStudio Code] 言語によってインデント幅を変更する

やること

Java, Ruby, C#, Python, JavaScriptのインデント幅をそれぞれ設定する。

手順

今回はWindowsなので、Ctrl+Shift+Pでコマンドパレットを開きます。
Preferences: Configure Language Specific Settingsを選択します。
image.png
そして、設定したい言語を選択します。
image.png

例として、今回はjavaを選択します。
すると、setting.jsonに下記の内容が設定されます。

    "[java]": {

    }

ここに、インデント幅と、タブとスペースどちらを使うかを設定します。
例はJavaなので、インデント幅はスペース4個、タブをスペースに変換します。

    "[java]": {
        "editor.tabSize": 4,
        "editor.insertSpaces": true
    },

上の手順を繰り返して、他の言語も設定していきます。

    "[ruby]": {
        "editor.tabSize": 2,
        "editor.insertSpaces": true
    },
    "[java]": {
        "editor.tabSize": 4,
        "editor.insertSpaces": true
    },
    "[csharp]": {
        "editor.tabSize": 4,
        "editor.insertSpaces": true
    },
    "[python]": {
        "editor.tabSize": 2,
        "editor.insertSpaces": true
    },
    "[javascript]": {
        "editor.tabSize": 2,
        "editor.insertSpaces": true
    }

最後に(雑談)

MacでVSCode + Google日本語入力のサジェストが入力文字列とかぶる問題。
どうにかしてほしい。

99
74
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
99
74