I would like to configure the vscode to format my JSON objects with 2 spaces of indent, not 4 as it does by default. How can I do this?
Type “Indentation” into the search field then head to the “Editor: Tab Size” section. Replace the default space number with your preferred one: Your setting will be applied and reflected immediately. If this doesn't happen (it's a little lag sometimes), just reload or restart your VS Code.
Formatting# You can format your JSON document using Ctrl+Shift+I or Format Document from the context menu.
json file. 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.
Paste in this lines in settings.json in VSCode, and you're all set:
"[json]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
}
Install the editor config plugin.
ext install EditorConfig
Add an .editorconfig
file to your project root with the following:
[*.json]
indent_style = space
indent_size = 2
See also:
https://github.com/editorconfig/editorconfig-vscode
http://editorconfig.org/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With