How to change the per-language configuration of se

2019-03-24 05:21发布

问题:

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?

回答1:

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