Wednesday, September 14, 2011

Re: Delete whole line with substitute

On 09/14/11 04:55, Christian Brabandt wrote:
> But of course you can achieve the same using a :s command. In your case
> you only forgot to include the "\n" in your pattern, so Vim leaves it
> in, which means you still have an empty line, but including it in your
> :s command should also work:
>
> :%s/foobar\n//
>
> deletes all lines ending in foobar.

Just be clear (which it looks like the OP figured out), you would
really want

:%s/.*foobar\n//

Otherwise it will just delete from "foobar" through-and-including
the EOL. However, sometimes that *is* what you want, so it's
nice that Vim offers that too.

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