How to set per-filetype tab size?

Ron picture Ron · Dec 13, 2015 · Viewed 29.5k times · Source

How to set tab size is already answered here.

But how to have different settings for different file types? E.g. I want the tab size for HTMLs to be 2, but for other files to be 4.

Answer

randomguy04 picture randomguy04 · Nov 7, 2017

VS Code configures language specific settings in settings.json

  • Shortcut is: Command Palette (⇧⌘P) then: Preferences: Configure Language Specific Settings

Example of setting.json changing tabsize

{
    "[sass]": {
        "editor.tabSize": 2
    },
    "[html]": {
        "editor.tabSize": 4
    },
    "[javascript]": {
        "editor.tabSize": 2
    }
}

These are not nested inside any other object, they are defined at the root.