Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 433
Guss Avatar asked May 05 '15 15:05

Guss


People also ask

How do I enable auto format in VS Code?

VS Code Auto Format On SaveOpen Visual Studio Code editor. Click the “Settings” gear icon in the bottom-left corner. Search “Formatter” and click the “Editor: Default Formatter” option. From the drop-down menu, select whichever code formatter you want to use.

How do I change JSON settings?

You can open the settings.json file with the Preferences: Open Settings (JSON) command in the Command Palette (Ctrl+Shift+P). Once the file is open in an editor, delete everything between the two curly braces {} , save the file, and VS Code will go back to using the default values.


1 Answers

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

like image 171
jbtule Avatar answered Sep 18 '22 05:09

jbtule