Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove double spacing

Sometimes, copy pasting code from my email makes everything have an extra blank line.

For example

1: hi
2:
3: hello
4:

Is there a way to target these empty lines with regex and delete them? I'm using notepad++ with the search(with regex) and replace capability.

like image 715
dukevin Avatar asked Apr 22 '11 18:04

dukevin


1 Answers

Because Notepad++ regex operates only line by line, without a multi-line mode, you can't remove entire lines with regex alone. This is no longer true as of Notepad++ 6.0, which now uses PCRE as its regex engine and allows for multi-line replacements. See this answer for more info.

The TextFX plugin that Notepad++ ships with allows you to remove blank lines without using regex. Just highlight your entire document (Ctrl+A) and do TextFX > TextFX Edit > Delete Blank Lines. If your selection or document begins and/or ends with a blank line though, those lines won't be removed automatically — but removing those is just a matter of:

  1. Ctrl+Home

  2. Del

  3. Ctrl+End

  4. Backspace

like image 57
BoltClock Avatar answered Sep 27 '22 20:09

BoltClock