Press: Ctrl + H on PC, or. Command + Alt + F on Mac or.
There is also a very handy keyboard shortcut to delete rows (columns or cells). Press Ctrl + – on the keyboard. That's it! Our blank rows are gone now.
Delete blank lines using the grep command When used with the -v option, the grep command helps to remove blank lines. Below is a sample text file, sample. txt, with alternative non-empty and empty lines. To remove or delete all the empty lines in the sample text file, use the grep command as shown.
Select the text
Press:
Make sure you have selected 'regular expression' by pressing:
Find what: ^\n
or ^(\r|\n\r?)
Replace With: (nothing, leave in blank).
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+$
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
A Find/Replace solution:
Regex Find:\s+
Replace with: //single space
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}
I had to use:
replace \n^\s*\n with \n
The https://github.com/NicholasBuse/sublime_DeleteBlankLines plugin did nothing at all.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With