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
The Comments of @crates work for me,
Step 1: Simply press on ctrl+H
Step 2: press on RegEX key
Step 3: write this in the Find: ^[\s]*?[\n\r]+
Step 4: replace all
I had to use:
replace \n^\s*\n with \n
The https://github.com/NicholasBuse/sublime_DeleteBlankLines plugin did nothing at all.
Don't even know how this whole thing works, but I tried
^\s*$
and didn't work (leaving still some empty lines).
This instead ^\s*
works for me
{sublime text 3}
In my case some empty lines contained the unicode character zero width space (U+200b). To rid empty lines, including the ones with this unicode character:
\s\x{200b}|^\s
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.
The regexp in Hugo's answer is correct when there is no spaces in the line. In case if there are space regexp can be ^\s+$