[POST]
VS Code Setup
2018-10-30● 5 min read
How to change default indentation?
Global setting (applies to all projects)
- Open Command Palette → Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac).
- Search for "Preferences: Open User Settings".
- Search for "Tab Size".
- Change:
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false
- tabSize: 2 → 2 spaces
- insertSpaces: true → use spaces, not tabs
- detectIndentation: false → prevents VS Code from auto-detecting indentation from the file and overriding your setting
Workspace setting (applies only to one project)
- In your project, create or edit .vscode/settings.json.
- Add:
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false
}
Language-specific (optional, if you want different settings per language)
For example, for JavaScript:
"[javascript]": {
"editor.tabSize": 2,
"editor.insertSpaces": true
}