Emacs Delete Double Blank Lines


Working through documents prepared by others, you frequently find the text littered with multiple blank lines.

An easy way to eliminate these blanks while working through the text is to use delete-blank-lines function in Emacs. This useful tool removes all superfluous blanks around the point (cursor), leaving a single blank in place. Its a great to use though it does require you to navigate to the blanks before running the function.

Its so simple. To see it in action, move to a place with several blanks and hit the key combo:

C-x C-o

Here's how it works:

On blank line, delete all surrounding blank lines, leaving just one
On isolated blank line, delete that one
On nonblank line, delete any immediately following blank lines