Whitescrub
Tidy whitespace across the whole file — in one command.
Whitescrub cleans the most common whitespace nuisances: trailing spaces, stray leading indentation, walls of blank lines, and messy file endings. Each command rewrites the entire document, so there is nothing to select first.
Features
- Trim Trailing Whitespace — removes spaces and tabs at the end of every line, leaving indentation untouched.
- Trim Leading Whitespace — removes spaces and tabs at the start of every line.
- Collapse Multiple Blank Lines — squeezes runs of two or more blank lines down to a single empty line.
- Ensure Single Final Newline — strips trailing blank lines so the file ends with exactly one newline.
- Scrub All — runs trim-trailing, collapse-blank, and ensure-final-newline together in one pass.
After each run, Whitescrub reports how many lines it changed.
Usage
- Open the file you want to clean up.
- Open the Command Palette (
Ctrl+Shift+P / Cmd+Shift+P).
- Run any Whitescrub: command.
If a command would make no difference, Whitescrub tells you there was nothing to clean up and leaves the file unchanged.
Note on line endings
Whitescrub normalises line endings to LF (\n) while it works. If your project prefers CRLF, VS Code's Files: EOL setting will re-apply it on save.
Tips
Bind Whitescrub: Scrub All to a keyboard shortcut via Preferences: Open Keyboard Shortcuts and searching for whitescrub.
License
Licensed under the MIT License. See the LICENSE file included in this extension.