AR

ASHISH RANJAN

[POST]

VS Code Setup

2018-10-30● 5 min read

How to change default indentation?

Global setting (applies to all projects)

  1. Open Command Palette → Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac).
  2. Search for "Preferences: Open User Settings".
  3. Search for "Tab Size".
  4. 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)

  1. In your project, create or edit .vscode/settings.json.
  2. 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
}
;