Thursday, July 5, 2012

Re: How to remove empty lines except of one

On 07/04/12 23:11, Chris Jones wrote:
> On Wed, Jul 04, 2012 at 10:52:47PM EDT, Tim Chase wrote:
>> :%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

It might be slightly more efficient, as replacing the "2" case with
\r\r is a NOOP.

As for blank-ish lines (containing just whitespace), it might become
something like

%s/^\(\s*\n\)\+/\r

-tim


--
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: