Skip to content

Instantly share code, notes, and snippets.

@ekreutz
Last active February 2, 2024 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekreutz/539d3fb0d4a292660583d12e86d76b82 to your computer and use it in GitHub Desktop.
Save ekreutz/539d3fb0d4a292660583d12e86d76b82 to your computer and use it in GitHub Desktop.
Trim empty lines in VSCode

How to trim empty lines in VSCode

What this will do:

  • Trim empty lines (remove all whitespace)
  • Trim whitespace at the end of code lines
  • Note: it will not remove any line at all, but simply trim trailing whitespace.

Steps:

  1. Press Ctrl + F (Cmd + F on mac) to open the search and replace view.
  2. Toggle the regex button .*.
  3. Paste ([ \t])+$ in the Find field, and leave the Replace field empty.
([ \t])+$
  1. Click replace all.

Done.


It would look like this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment