M-x all-things-emacs

Quick Tip: delete-blank-lines

June 7th, 2007 by Ryan McGeary · 12 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.

Before:
delete-blank-lines before
After:
delete-blank-lines after
 

Tags: quick · tips

12 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)
              (save-excursion
                (beginning-of-line)
                (looking-at "^\\s *$")))
          (delete-blank-lines)
          (fixup-whitespace)))
  • 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?

  • 4 Con-Cret Amino Tren // Jul 23, 2015 at 4:20 pm

    ... [Trackback]

    [...] There you will find 78506 more Infos: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 5 amazin gas station video // Jul 24, 2015 at 9:03 am

    ... [Trackback]

    [...] Informations on that Topic: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 6 amazin gas station video // Jul 24, 2015 at 10:32 am

    ... [Trackback]

    [...] Read More: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 7 drinking and driving // Jul 24, 2015 at 9:28 pm

    ... [Trackback]

    [...] There you will find 73931 more Infos: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 8 Airport car service atlanta // Jul 25, 2015 at 1:49 pm

    ... [Trackback]

    [...] Read More here: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 9 Locksmith Rancho Cordova // Jul 26, 2015 at 6:24 am

    ... [Trackback]

    [...] Informations on that Topic: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 10 there // Jul 27, 2015 at 9:02 am

    ... [Trackback]

    [...] There you will find 35209 more Infos: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 11 regular cleaning // Jul 27, 2015 at 6:26 pm

    ... [Trackback]

    [...] There you will find 30652 more Infos: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]

  • 12 surf shop // Jul 28, 2015 at 6:41 am

    ... [Trackback]

    [...] Read More here: emacsblog.org/2007/06/07/quick-tip-delete-blank-lines/ [...]