json - Auto-indent rules for file extension in Visual Studio Code (vscode)? -
is there way tell visual studio code apply specific auto-indent rules given file extension? our current settings.json file is:
{ "editor.tabsize": 4, "editor.insertspaces": true, "files.associations": { "**/src/**/*.js": "javascriptreact" } } i did try following, did not work me:
{ "files.associations": { "**/src/**/*.js": "javascriptreact", "package.json": "json" }, "[javascriptreact]": { "editor.insertspaces": true, "editor.tabsize": 4 }, "[json]": { "editor.insertspaces": true, "editor.tabsize": 2 } } i did experiment [*.json], did not work either.
i using visual studio code 1.15.0.
[for simplicity, i'll put various solutions answer.]
vscode has handy way edit language-specific editor settings.
ctr-shift-p : preferences: configure language specific settings...
and chose language. choosing "javascript react" open , create entry in settings.json file can add javascript react specific editor settings number of spaces use tab.
oddly though, new settings entry appended end of file while file not automatically scrolled point. scroll end of settings.json file find new language-specific entry. can put things :
"[json]": { "editor.detectindentation": false, "editor.tabsize": 4, "editor.insertspaces": true } note "editor:detectindentation" defaulted true must change false tabsize , insertspaces have effect. making above change within settings.json file show working within json file (see spaces: # item in lower right corner of editor).
however, these settings not change existing spacings within file, new tabs reflect changes...
unless have conflicting extension sets same editor settings. knew "prettier" extension so. op @andre m reports extension "beautify" conflicts spaces tabs.
wiki
Comments
Post a Comment