Skip to content

/config/vscode/format-on-save-settings

VS Code format on save: editor.formatOnSave and default formatters

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
VS Code
file
settings.json (user) or .vscode/settings.json (workspace)
key
editor.formatOnSave
type
boolean
default
false

"editor.formatOnSave": true makes VS Code run the document formatter every time you save. Which formatter runs is decided by editor.defaultFormatter, globally or per language. Put the settings in the project's .vscode/settings.json so everyone who opens the repository gets the same behaviour.

A typical project setup

.vscode/settings.json
{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  },
  "[python]": {
    "editor.defaultFormatter": "charliermarsh.ruff"
  },
  "[makefile]": {
    "editor.insertSpaces": false
  }
}
.vscode/extensions.json
{
  "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "charliermarsh.ruff"]
}

extensions.json makes VS Code suggest the extensions the settings refer to.

SettingEffect
editor.formatOnSaveformat the whole file on save
editor.formatOnSaveModefile (default), modifications or modificationsIfAvailable (only changed lines, needs source control)
editor.defaultFormatterextension ID of the formatter to use
editor.codeActionsOnSaverun code actions such as ESLint fixes or organize imports on save
editor.formatOnPasteformat pasted text
files.trimTrailingWhitespaceremove trailing spaces on save

If nothing happens on save, open the Command Palette and run Format Document With…: when several formatters are installed and none is the default, VS Code asks you to choose instead of formatting. The Output panel, channel of the formatter extension, shows its errors.

Sources