Skip to content

Instantly share code, notes, and snippets.

@aissam-en
Created December 26, 2025 11:50
Show Gist options
  • Select an option

  • Save aissam-en/62c3156394b167257c6dc22c0a368095 to your computer and use it in GitHub Desktop.

Select an option

Save aissam-en/62c3156394b167257c6dc22c0a368095 to your computer and use it in GitHub Desktop.
Remove all empty lines using regex - VSCode

Remove all empty lines in VSCode using regex

Steps

  1. Ctrl + H (Windows/Linux)
  2. click the .* icon ("Use Regular Expression")
  3. in the Find field, use:
^(\s)*$\n
  1. leave the Replace field empty
  2. click Replace All

Explanation :

  • ^ : start of line
  • (\s)* : any whitespace (spaces, tabs)
  • $ : end of line
  • \n : newline character
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment