M-x all-things-emacs

Quick Tip: delete-blank-lines

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

46 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/ [...]

  • 13 Click Here // Jul 31, 2015 at 6:18 pm

    ... [Trackback]

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

  • 14 Prodaja staklene ambalaze // Aug 1, 2015 at 4:37 am

    ... [Trackback]

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

  • 15 security services // Aug 1, 2015 at 6:23 pm

    ... [Trackback]

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

  • 16 www.tiptopplumbers.com // Aug 2, 2015 at 6:17 pm

    ... [Trackback]

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

  • 17 What materials will be needed for the repair itself? // Aug 2, 2015 at 7:31 pm

    ... [Trackback]

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

  • 18 plumbing repair // Aug 2, 2015 at 8:35 pm

    ... [Trackback]

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

  • 19 asphalt roofing // Aug 2, 2015 at 10:23 pm

    ... [Trackback]

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

  • 20 cheap order ventolin 100 mcg // Aug 3, 2015 at 1:36 pm

    ... [Trackback]

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

  • 21 central air conditioner humidifier // Aug 4, 2015 at 1:22 am

    ... [Trackback]

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

  • 22 installing glass block windows // Aug 4, 2015 at 1:26 am

    ... [Trackback]

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

  • 23 emergency generators for the home // Aug 4, 2015 at 2:13 am

    ... [Trackback]

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

  • 24 supremecontracting.net // Aug 4, 2015 at 2:48 am

    ... [Trackback]

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

  • 25 skillfullcontracting.com // Aug 5, 2015 at 6:57 am

    ... [Trackback]

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

  • 26 social signals service // Aug 5, 2015 at 7:05 am

    ... [Trackback]

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

  • 27 a fantastic read // Aug 5, 2015 at 10:42 am

    ... [Trackback]

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

  • 28 rich mom software // Aug 7, 2015 at 3:43 pm

    ... [Trackback]

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

  • 29 where to check my social signals count // Aug 8, 2015 at 10:10 pm

    ... [Trackback]

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

  • 30 click this link here now // Aug 9, 2015 at 6:27 pm

    ... [Trackback]

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

  • 31 look at this website // Aug 9, 2015 at 6:55 pm

    ... [Trackback]

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

  • 32 you can try this out // Aug 10, 2015 at 10:21 pm

    ... [Trackback]

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

  • 33 al3ab // Aug 11, 2015 at 12:09 am

    ... [Trackback]

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

  • 34 view // Aug 12, 2015 at 10:21 pm

    ... [Trackback]

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

  • 35 http://www.chiefelectrical.net // Aug 13, 2015 at 11:44 pm

    ... [Trackback]

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

  • 36 http://majesticplumbers.com // Aug 14, 2015 at 12:00 am

    ... [Trackback]

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

  • 37 you could check here // Aug 14, 2015 at 4:35 am

    ... [Trackback]

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

  • 38 http://www.principalwindows.com // Aug 14, 2015 at 4:58 am

    ... [Trackback]

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

  • 39 How do I determine the exact property line? // Aug 14, 2015 at 6:37 am

    ... [Trackback]

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

  • 40 www.originalhandymen.com // Aug 14, 2015 at 6:40 am

    ... [Trackback]

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

  • 41 furniture removal company // Aug 14, 2015 at 7:28 am

    ... [Trackback]

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

  • 42 www.standouthvac.com // Aug 14, 2015 at 1:51 pm

    ... [Trackback]

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

  • 43 black mold remediation // Aug 14, 2015 at 1:53 pm

    ... [Trackback]

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

  • 44 Social Signals // Aug 14, 2015 at 10:11 pm

    ... [Trackback]

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

  • 45 try this // Aug 14, 2015 at 10:21 pm

    ... [Trackback]

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

  • 46 clickfunnels pricing // Aug 14, 2015 at 10:30 pm

    ... [Trackback]

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