User and workspace settings

VS Code · Practical · 10 min

Settings like format-on-save and per-project rules make the editor do the right thing automatically for every teammate.

Open settings with Ctrl+,. The UI is searchable; the {} icon in the top right opens the underlying settings.json, which is what most people edit directly.

Settings exist at several levels, the more specific winning:

  • User settings apply to every window.
  • Workspace settings live in .vscode/settings.json inside the project and override user settings. Commit them to share project conventions with the team (formatter, tab size, excluded folders).
  • Language-specific blocks override both for one language: "[python]": { "editor.tabSize": 4 }.
  • In a multi-root workspace, folder settings are also possible.

Useful settings to know:

  • "editor.formatOnSave": true plus "editor.defaultFormatter" per language.
  • "editor.codeActionsOnSave" to run fixes such as organising imports or ESLint fixes on save.
  • "files.exclude" hides files from the Explorer; "search.exclude" from search.
  • "files.autoSave": "afterDelay" saves automatically.

settings.json is JSON with comments (jsonc), and IntelliSense completes setting names and values. Hovering a setting shows its description and default. Search for @modified in the Settings UI to see everything you changed from defaults.

Example

// .vscode/settings.json  (committed, shared with the team)
{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": { "source.organizeImports": "explicit" },
  "files.exclude": { "**/__pycache__": true, "**/.pytest_cache": true },
  "search.exclude": { "**/dist": true },
  "[python]": {
    "editor.tabSize": 4,
    "editor.defaultFormatter": "charliermarsh.ruff"
  },
  "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }
}

Remember

  • User < Workspace (.vscode/settings.json) < language-specific
  • Commit workspace settings to share project conventions
  • settings.json is JSON with comments; @modified shows changes

Watch out for

  • Putting personal preferences like themes or font size in the shared workspace settings.

Check yourself

  1. A user setting sets tabSize 2, the workspace sets 4, and a [python] block in the workspace sets 8. What is the tab size in a Python file?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: code.visualstudio.com/docs/configure/settings