VS Code Keyboard Shortcuts/Trim trailing whitespace

Remove trailing spaces in active file.

Section: Editor Editing

Trim trailing whitespace

text
text
Windows/Linux: Ctrl+K Ctrl+X
macOS: Cmd+K Cmd+X

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Editor Editing
Copy line up/down
Duplicate current line or selection.
OpenIn sheettextsame section
Join lines
Join selected lines or current line with next line.
OpenIn sheettextsame section
Toggle word wrap
Switch editor wrapping on and off.
OpenIn sheettextsame section
Change file language mode
Set syntax highlighting / language mode manually.
OpenIn sheettextsame section
New window
Open a new VS Code window.
Quick Open
Search and open files.