Let's say I had a text file with the following nine lines:
foo
bar
baz
qux
quux
How can I use Sublime Text 2 to remove all four of the blank/empty lines, leaving only five lines?
There are also some ST2/ST3 Plugins for such tasks. I do like these two:
The first one has two methods for removing empty/unnecessary lines. One of them called Delete Surplus Blank Lines which is cool. It removes only those lines that are followed by another empty line
I had to use:
replace \n^\s*\n with \n
The https://github.com/NicholasBuse/sublime_DeleteBlankLines plugin did nothing at all.
There is a wonderful package (for Sublime 2 & 3) called 'Trimmer' which deletes empty lines. It also does many other useful things.
Refer this: https://packagecontrol.io/packages/Trimmer
Using find / replace, try pasting a selection starting at the end of the line above the blank line and ends at the beginning of the line after the blank. This works for a single blank line. You can repeat the process for multiple blank lines as well. CTRL-H, put your selection in the find box and put a single newline in the replace box via copy/paste or other method.