VS Code settings.json example: font, tabs and format on save
Set font, tab size, format on save and theme in your VS Code settings.
VS Code stores your editor preferences in settings.json. Choose your options below to get the lines you need, then paste them into your user settings.
Create your config file
Type your own values. The file below updates as you type, and nothing you type leaves your browser.
{
"editor.fontSize": 14,
"editor.fontFamily": "Consolas, 'Courier New', monospace",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.wordWrap": "off",
"editor.minimap.enabled": false,
"files.autoSave": "afterDelay",
"workbench.colorTheme": "Default Dark Modern",
"files.trimTrailingWhitespace": true
}How this setup works
Step-by-step setup
- Press Ctrl+Shift+P (Mac: Cmd+Shift+P) and run Preferences: Open User Settings (JSON).
- If the file already has settings, do not replace them. Copy only the lines you want inside the existing braces.
- Save the file. VS Code applies it at once.
- For format on save, install a formatter such as Prettier.
What the important lines mean
- editor.tabSize is 2 spaces per tab.
- editor.fontFamily only works if Consolas, 'Courier New', monospace is installed on your computer.
- files.autoSave is afterDelay: files save without pressing Ctrl+S unless it is off.
Common errors and how to fix them
- The font does not change
- Install the font from your list, for example Consolas, 'Courier New', monospace, then restart VS Code.
- Format on save does nothing
- Install a formatter extension such as Prettier and set it as the default formatter for that file type.
- Expected comma
- When merging, every line inside the braces needs a comma except the last one.
Frequently asked questions
- How do I open settings.json in VS Code?
- Press Ctrl+Shift+P (Cmd+Shift+P on a Mac) and run "Preferences: Open User Settings (JSON)".
- How do I turn on format on save?
- Set "editor.formatOnSave": true and install a formatter such as Prettier. The option does nothing without a formatter.
- Should I replace my whole settings.json?
- No. Copy only the lines you want into the existing braces, and keep a comma after each line except the last.
More developer configs
- .bashrc and .zshrc aliasesAdd handy shortcuts and settings to your terminal.
- .gitignore fileTick your languages and tools to get a .gitignore that keeps build files and secrets out of Git.
- .editorconfig fileMake every editor on your team use the same indent, line endings and encoding.
- GitHub Actions workflow for Node.jsA ci.yml file that installs, lints, builds and tests your Node.js project on GitHub.
- package.json fileCreate a package.json with the right name, version, module type, scripts and Node version.
- tsconfig.json fileCreate a tsconfig.json for a Node or browser TypeScript project, with strict mode, target and output folder.