Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Format Changed LinesNew to Visual Studio Code? Get it now.
Format Changed Lines

Format Changed Lines

Joel Gutiérrez Ruiz

|
57 installs
| (1) | Free
Format only what you changed. Uses Git to detect modified lines and applies your formatter — nothing else is touched.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Format Changed Lines

Stop formatting entire files. Only format the lines you actually changed.


This extension uses Git to detect your modifications and applies your VS Code formatter only to those lines. The rest of the file stays untouched — clean diffs, clean history.

Ideal for working with Copilot, Cursor, or any AI tool that generates unformatted code.

Note: Currently optimized for Java. Other languages with a VS Code formatter may work but have not been fully tested.

✨ Features

  • Git-powered — detects changed lines via git diff with bulk parsing (only 2 Git calls total).
  • Multi-file — formats all modified files at once.
  • Statement-aware — if you touched one line of a multi-line if() or method call, the whole statement gets formatted.
  • Smart reformat — joins broken statements into one line, then lets the formatter decide the correct layout.
  • Branch compare — pick any branch to compare against, not just HEAD. Format only the lines that differ from main, develop, or any other branch.
  • Any language — works with Java, TypeScript, Python, C#, or any language with a VS Code formatter.
  • New files — untracked files are fully formatted.
  • VDI-optimized — direct Git process spawning, no shell overhead, no console flashing on Windows.

🚀 Quick Start

  1. Write or edit code (manually or with AI).
  2. Press Ctrl+Alt+S to format changes against HEAD.
  3. Or press Ctrl+Alt+B to choose a branch first.
  4. Done. Files are formatted and saved.

📦 Requirements

  • Git installed and in PATH.
  • A Git repository with at least one commit.
  • A formatter extension for your language (Prettier, Java formatter, etc.).

⌨️ Keybindings

Command Shortcut Description
Format Changed Lines Ctrl+Alt+S Format changes compared to HEAD (uncommitted work)
Format Changed Lines (Select Branch) Ctrl+Alt+B Pick a branch from a list and format only the diff against it

Customizable in File > Preferences > Keyboard Shortcuts.

📝 Release Notes

1.2.0

  • Performance overhaul — optimized for VDI and low-resource environments.
  • Replaced shell-based Git calls (execSync) with direct process spawning (execFileSync) — eliminates cmd.exe overhead on Windows.
  • Bulk diff parsing — all file changes retrieved in 2 Git calls instead of N+2.
  • Removed artificial delays between files.
  • Hidden console windows on Windows (windowsHide).

1.3.0

  • Ignore rules — files in test paths and files ending in .json, .yml, or .yaml are skipped from formatting.
  • Ctrl+Alt+B updated — branch-compare formatting now also respects ignore rules (including tests).
  • Javadoc-safe formatting — blocks from /** to */ are formatted as a full selection and are not collapsed into one line.
  • Better multiline reflow — after internal line-join, formatting is applied with context lines so long statements can be split back correctly by the formatter.

Author: Joel Gutiérrez Ruiz

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft