If you try to figure out how to remove the blank lines in a document, i.e. the lines that contain only spaces, tabs or the newline characters, you should know that in almost any IDE, like a Sublime Text, this can de done really simple.
The Sublime Text, like the other IDEs, has the ability to delete empty lines in the “Replace” operation by using the “Regular expression”.
This short note shows how to remove empty lines in the Sublime Text.
Cool Tip: How to add a newline at the EOF on save in Sublime Text! Read more →
Remove Empty Lines in Sublime Text
Here is a step by step instruction for how to remove empty lines in the Sublime Text editor:
- Go to the
– or – press the Ctrl + H on Windows/Linux or ⌘ Cmd + Alt + F on Mac
- Select the ‘Regular expression‘ by clicking on the .* button in the
– or – press the Alt + R on Windows/Linux or ⌘ Cmd + Alt + R on Mac
- In the
Findfield, type in:
^\nto delete empty lines excluding the ones that contain whitespaces:
– or –
^(\r|\n\r?)to delete empty lines including ones with whitespaces:
- Leave the
- Click on the Replace All button
Cool Tip: How to enable spell checking in Sublime Text! Read more →