Thursday, July 5, 2012

Re: How to remove empty lines except of one

On 05/07/12 03:58, meino.cramer@gmx.de wrote:
> Hi,
>
> (using vim v.:7.3.584 under Gentoo-Linux with most features set on)
>
> I tried things like
>
> :s/^\r\r\r/\r/g
>
> but with no success...
>
> How can I reduce a bunch of empty lines to one single empty line?
>
> Best regards,
> mcc
>
>
>

In addition to all that has already been said, maybe (untested)

:%s/^\n*$/\r/

would work too? (replacing any number of line breaks, as many as
possible, between a start-of-line and an end-of-line, by one line break).

One of the good things with Vim is that often there are many solutions
to a single problem.


Best regards,
Tony.
--
GUARD #1: What, ridden on a horse?
ARTHUR: Yes!
GUARD #1: You're using coconuts!
ARTHUR: What?
GUARD #1: You've got two empty halves of coconut and you're bangin' 'em
together.
The Quest for the Holy Grail (Monty
Python)

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