Vscode Language Specific Configs

Tue Dec 10 2019

Vscode injected itself to the hearts of many developers around the globe quite quickly.

I love it and especially the way I can easily configure it to what I need.

For quite some time I was struggling with a project that had different languages that required different tab sizes (2 or 4).

I tried several tricks to resolve that pain.

loaded the main project folder and ignore the sub folder that contains the other language. That helped a bit, but there were configs in the root folder that were needed in the sub folder.

Second, I opened two vscode instances one for each type of code. annoying.

The solution

Simply have different config per language. So I could easily define different tab size per languge or any other config I needed.

  "global_config_here": "...",
  "editor.tabSize": 4
  //only javascript files configs now
  "[javascript]": {
      "editor.tabSize": 2
  //only javascript-react files configs now
  "[javascriptreact]": {
      "editor.tabSize": 2