23

I'm using VS Code to edit projects in multiple languages (mostly Ruby, PHP and Javascript) and for each language we have different indentation models (spaces/tabs and width). Looks like VS Code supports this as it allows both editor.insertSpaces and editor.tabSize to be set to "auto" which is a per-language definition.

But while editor.tabSize looks to do about what I want, editor.insertSpaces always insert spaces when in "auto" mode.

I've tried to find where one can edit the per-language configuration but have found no such setting. I've also looked in the language directories under resources/app/client/vs/languages but have failed to find something that specifies these features.

Any idea how to customize the per-language settings?

Guss
  • 30,470
  • 17
  • 104
  • 128
  • I wish `vscode` start supporting plugins and specially `editorconfig` for this use case. – Sarbbottam May 05 '15 at 23:02
  • Please suggest this as a feature on our User Voice page: http://visualstudio.uservoice.com/forums/293070-visual-studio-code – Benjamin Pasero May 06 '15 at 17:06
  • i've opened [uservoice ticket #7853865](http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7853865-allow-to-configure-the-auto-behavior-of-features) – Guss May 07 '15 at 09:51

1 Answers1

23

To use perlanguage settings, you use the [language_id] in square brackets:

example:

{
  "[typescript]": {
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true
  },
  "[markdown]": {
    "editor.formatOnSave": true,
    "editor.wrappingColumn": 0,
    "editor.renderWhitespace": "all",
    "editor.acceptSuggestionOnEnter": false
  }
}

Update: editor.tabSize and editor.insertSpaces are now supported in version 1.10

jbtule
  • 31,383
  • 12
  • 95
  • 128
  • 1
    Thank you for the note on future support. That is what I came here for . – Strake Feb 17 '17 at 04:38
  • 2
    @Strake it's supported now!! – jbtule Mar 01 '17 at 21:22
  • How do I do multiple languages ? – DollarAkshay Jan 24 '19 at 14:01
  • 1
    Fwiw, [to see a list of languages supported](https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings)... "*To customize your editor by language, run the global command Preferences: Configure Language Specific Settings (command id: `workbench.action.configureLanguageBasedSettings`) from the Command Palette (⇧⌘P) which opens the language picker. Selecting the language you want, opens the Settings editor with the language entry where you can add applicable settings.*" Also had to restart VS Code, not just reopen window, for it to "take" when I did it initially. – ruffin Jun 22 '19 at 13:17