Remove empty lines and spaces in Notepad++?

To get rid of leading space(s) and all empty lines (even if the empty line contains spaces or tabs)

  1. Go to Search -> Replace
  2. Select "Regular expression" under Search mode.
  3. Use ^\s* for "Find what" and leave "Replace with" blank.
  4. Click Replace all

Regex explanation:

  • ^ means beginning of the line
  • \s* means any number (even 0) of whitespace characters. Whitespace characters include tab, space, newline, and carriage return.

Edit -> Line Operations -> Remove Empty Lines or alternatively: Edit -> Line Operations -> Remove Empty Lines (Containing Blank characters)

enter image description here


Go to Edit > Line Operations > Remove Empty Lines

Tags:

Notepad++