How to change the per-language configuration of setting "editor.insertSpaces" to "auto"
Asked Answered
B

2

24

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?

Bumboat answered 5/5, 2015 at 15:51 Comment(3)
I wish vscode start supporting plugins and specially editorconfig for this use case.Homeland
Please suggest this as a feature on our User Voice page: visualstudio.uservoice.com/forums/293070-visual-studio-codePinzler
i've opened uservoice ticket #7853865Bumboat
S
25

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

Selfconscious answered 16/2, 2017 at 17:55 Comment(4)
Thank you for the note on future support. That is what I came here for .Nabonidus
@Nabonidus it's supported now!!Selfconscious
How do I do multiple languages ?Accost
Fwiw, to see a list of languages supported... "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.Largish
F
0

From the documentation:

One way to customize language-specific settings is by opening the Settings editor (Ctrl+,), pressing on the Filter button, and selecting the language option to add a language filter. Alternatively, one can directly type a language filter of the form @lang:languageId into the search widget.

enter image description here

Fornicate answered 23/7 at 20:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.