M-x all-things-emacs

Quick Tip: delete-blank-lines

June 7th, 2007 by Ryan McGeary · 3 Comments

The delete-blank-lines function is a simple yet handy tool to have in your bag of tricks. It is bound to C-x C-o. There isn’t a whole lot of magic surrounding it’s usage, so I’ll just quote the built-in help directly:

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.

delete-blank-lines before
delete-blank-lines after

Tags: quick · tips

3 responses so far ↓

  • 1 sean // Jun 7, 2007 at 6:13 pm

    Cool! One of these days I need to just read through all of simple.el. One nice improvement might be to combine this with fixup-whitespace like so:

    (defun my-fixup-whitespace ()
      (interactive "*")
      (if (or (eolp)
                (looking-at "^\\s *$")))
  • 2 Gunter // Dec 6, 2007 at 5:03 am

    This technique of deletting blank lines , is that done using Word or is it done some otherway?

  • 3 Ryan McGeary // Dec 6, 2007 at 9:08 pm

    Gunter, Wha?