28

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?

asked May 5, 2015 at 15:51
3

2 Answers 2

31

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

You can specify multiple languages too: "[typescript][markdown]": ....

HolyBlackCat
102k13 gold badges181 silver badges302 bronze badges
answered Feb 16, 2017 at 17:55
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for the note on future support. That is what I came here for .
@Strake it's supported now!!
How do I do multiple languages ?
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.
4

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

answered Jul 23, 2024 at 20:47

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.