Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 40 ยท Interface and Settings

Settings: The UI and settings.json

Change VS Code behavior with the Settings UI and settings.json: search settings, understand JSONC, learn essential settings like autosave and format on save, and fix errors.

Almost everything in VS Code is configurable. Settings control how the editor wraps lines, when files save, which formatter runs, how the terminal looks and what extensions do. You can change them in two ways: a friendly Settings UI and a plain text file, settings.json. Both edit the same data.

The Settings UI

Open it with Ctrl+, (Cmd+, on macOS), or through File > Preferences > Settings. You will see a search box, a list of categories on the left (Commonly Used, Text Editor, Workbench, Window, Features, Application, Extensions) and the settings themselves.

Tips for finding things:

  • Type a word and the list filters: try tab size, autosave, wrap.
  • Type @modified to see only the settings you changed.
  • Type @ext:ms-python.python to see one extension's settings.
  • Type @tag:usesOnlineServices or @lang:python to filter by tag or language.
  • Hover over a setting to see its ID, such as editor.tabSize, and click the gear for Copy Setting ID or Reset Setting.

A small blue bar beside a setting means you changed it from the default. Checkboxes, dropdowns and text boxes edit the value directly.

Opening settings.json

For anything not covered by a control (objects, arrays, per-language rules) you edit the JSON file. Open the Command Palette and run Preferences: Open User Settings (JSON). The file is created on first use. On disk it lives at:

  • Windows: %APPDATA%\Code\User\settings.json
  • macOS: ~/Library/Application Support/Code/User/settings.json
  • Linux: ~/.config/Code/User/settings.json

A realistic file:

JSON
{
  // Saving
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000,
  "editor.formatOnSave": true,

  // Reading comfort
  "editor.fontSize": 15,
  "editor.wordWrap": "on",
  "editor.minimap.enabled": false,

  // Indentation
  "editor.tabSize": 2,
  "editor.insertSpaces": true,
  "editor.detectIndentation": true,

  // Appearance
  "workbench.colorTheme": "Default Dark Modern",

  // Per-language override
  "[python]": {
    "editor.tabSize": 4
  }
}

JSON with comments (JSONC)

Notice the // comments. VS Code's settings use JSONC, JSON that allows comments and trailing commas. Normal JSON does not. This matters if you copy your settings into another program that expects strict JSON. Rules to remember:

  1. Every setting is a "key": value pair inside one pair of curly braces.
  2. Pairs are separated by commas; a trailing comma after the last pair is accepted.
  3. Strings use double quotes; booleans are true and false with no quotes.
  4. IntelliSense in the file suggests setting names and valid values: press Ctrl+Space inside the quotes.

A missing comma or quote shows a red squiggle, and the Problems panel explains the error. If the file has a syntax error, VS Code may ignore the whole file until you fix it, so watch for those squiggles.

A stand-in: parsing JSONC

VS Code's real parser is more complete. This simplified JavaScript stand-in removes comments and trailing commas, then parses the result so you can see why comments are legal in the settings file but not in standard JSON.

JS Stand-in: reading a settings file

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Essential settings to know

Setting Meaning
files.autoSave off, afterDelay, onFocusChange, onWindowChange
editor.formatOnSave Run the formatter every time you save
editor.tabSize / editor.insertSpaces Indent width and spaces versus tabs
editor.wordWrap off, on, wordWrapColumn, bounded
editor.fontSize, editor.fontFamily, editor.fontLigatures Text appearance
editor.rulers Vertical guide lines, e.g. [80, 100]
editor.renderWhitespace Show spaces and tabs (none, boundary, all)
files.trimTrailingWhitespace Remove trailing spaces on save
files.insertFinalNewline Ensure the file ends with a newline
files.exclude Hide files and folders from the Explorer
search.exclude Skip folders when searching
terminal.integrated.fontSize Terminal font size
window.zoomLevel Zoom the whole interface

Setting IDs follow a pattern, area.name, and the Settings UI shows them. An example of an object-valued setting:

JSON
"files.exclude": {
  "**/.git": true,
  "**/node_modules": true,
  "**/*.log": true
}

Per-language settings

Put a language ID in square brackets to override settings for one language only:

JSON
"[markdown]": {
  "editor.wordWrap": "on",
  "editor.quickSuggestions": { "other": false }
},
"[javascript]": {
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

The language ID of the current file is shown in the Status Bar, and you can see all IDs with Change Language Mode. In the Settings UI, click the dropdown near the search box or type @lang:python.

Defaults and resetting

The full default list is available through Preferences: Open Default Settings (JSON), a read-only file; use it to discover names. To go back to a default, delete the key from your file or click Reset Setting in the UI. Deleting the whole file resets everything. A user can also sync settings across machines; see Customization and Productivity.

Settings come from several layers, and the next lesson explains which one wins: User, Workspace and Folder Settings.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which shortcut opens the Settings UI?

    Ctrl+, (Cmd+, on macOS) opens Settings; Ctrl+K Ctrl+S opens the keyboard shortcuts.
  2. 2. What is special about the format of settings.json?

    VS Code uses JSONC, so // comments and trailing commas are accepted.
  3. 3. What does the key [python] with braces around settings mean?

    A language ID in brackets applies the nested settings only to files of that language.
  4. 4. How can you list only the settings you changed in the UI?

    The @modified filter shows settings that differ from the defaults.

Summary

  • Settings are edited in the Settings UI (Ctrl+,) or in settings.json.
  • The file is JSONC: comments and trailing commas are allowed.
  • Common settings: autosave, format on save, tab size, word wrap, font, excludes.
  • "[language]": { ... } overrides settings for one language.
  • Use @modified and the setting ID tooltip to find and copy settings.

Next: User, Workspace and Folder Settings