Keep VS Code Formatting Consistent with Committed Workspace Settings
Learn how a committed .vscode/settings.json file can stop whitespace churn and keep formatting uniform across a team while still allowing personal preferences.
28 Jul 2026, 18:50 UTC

The problem: formatting churn in team diffs
When each developer’s VS Code user settings differ — tabs versus spaces, different default formatters, or format‑on‑save toggled on for some and off for others — the repository diff fills with whitespace changes that carry no functional meaning. Reviewers spend time chasing these noisy changes, and continuous‑integration pipelines may fail on formatting checks that fluctuate from machine to machine.
Why workspace settings solve it
VS Code applies settings in the order: defaults → user settings → remote (machine) settings → workspace settings → folder settings in a multi‑root workspace. A committed .vscode/settings.json lives in the workspace layer, so it overrides any conflicting user preference while still letting developers keep personal tweaks (themes, fonts, keybindings) in their user settings file. Language‑scoped blocks like "[python]" further let you set a formatter or format‑on‑save only for that language.
Worked example: a minimal .vscode/settings.json
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.formatOnSave": true
}
}
This snippet forces two‑space indentation with spaces, ensures a trailing newline and removes stray whitespace. Inside the "[python]" block it tells VS Code to use the Python extension’s formatter and to run it on every save, while other languages keep whatever formatter the user has configured.
Pairing with .editorconfig and extension recommendations
VS Code does not natively understand EditorConfig; the popular EditorConfig extension provides that support. Adding an .editorconfig file at the repository root gives the same indentation rules to editors that lack the extension, and committing .vscode/extensions.json with a recommendation for the EditorConfig extension helps teammates install it automatically.
Trade‑offs and Workspace Trust considerations
Because workspace settings win over user settings, a teammate who dislikes a project‑wide choice must either edit the shared .settings.json (dirtying their checkout), use folder‑level settings in a multi‑root workspace, or accept the convention. Additionally, when Workspace Trust places a folder in Restricted Mode, VS Code blocks certain workspace settings as a security guard. Teams should verify that the settings they rely on (indentation, final newline, format‑on‑save) still apply in both trusted and restricted modes, or document any that are disabled.
Actionable close: what to commit and what to leave personal
Commit the parts of your editor configuration that the codebase needs to stay correct: indentation style, trailing‑whitespace handling, final newline, file‑association defaults, and per‑language format‑on‑save rules. Keep themes, fonts, icon sets, keybindings, and other aesthetic preferences in the user settings file. This split gives the team a deterministic formatting baseline while preserving individual comfort.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.