How to set per-filetype tab size?

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.


In addition to the other answers, you can set a default, and then set file-specific sizes.

  "editor.tabSize": 2,     // default
  "[elm]": {               // specific only to .elm files
      "editor.tabSize": 4
  },

With vscode v1.63 you will be able to "group" languages in language-specific settings like this:

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

This already can be done in the colorCustomizations setting like:

"workbench.colorCustomizations": {
    "[GitHub Sharp][GitHub Sharp Dark]": {
       "editorPane.background": "#d6d0d01a",
       "sideBarSectionHeader.border": "#D3D3D3",
    }
}

See Multiple languages specific editor settings