Wednesday, July 4, 2012

Re: How to remove empty lines except of one

On Wed, Jul 04, 2012 at 10:52:47PM EDT, Tim Chase wrote:

> For some reason (legacy?), Vim uses \n on the left side and \r on the
> right side,

Ah.. good one.. baffled me for ages and always had something more urgent
to do.. never got a chance or remembered to look into it.. and kicked
myself later when I ran into it again..

Thanks for sharing..!

> so you want something like

> :%s/\n\{2,}/\r

> optionally tweaking the "2" and the number of "\r"s for your
> particular use-case

With the eol that terminates non-empty lines, shouldn't it be¹:

| :%s-\n\{3,\}-\r\r-g

?

CJ

¹ And possibly also adding '\s\{1,\}' or '\s*' for white space..

--
HOW ARE YOU GENTLEMEN?

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment