Deleting Blank Lines

The Learn Emacs Twitter feed has a handy tip for dealing with blank lines:

It turns out that the delete-blank-lines command is a little more nuanced than that. The actual rules for invoking it (according to the documentation) are:

  1. If the point is on a blank line surrounded by others, delete all the surrounding blank lines, leaving just one.
  2. If the point is on an isolated blank line, delete that line.
  3. If the point is on a nonblank line, delete any blank lines that immediately follow.

This isn’t a command that I’d use everyday but it seems perfect for cleaning up a text file with lots of blank lines. Often times, I see imported data like this so it’s worth remembering the command.

This entry was posted in General and tagged . Bookmark the permalink.