Saturday, May 22, 2010

Re: Replacements with return

On 05/22/2010 05:01 PM, leandromartinez98 wrote:
> I'm trying do replace strings that contain return characters.
> I tried many things, as:
>
> :g/\n0\n/s//\n1\n/g
> :g/\n0\n/s//\r1\r/g
> (and all combinations of \r and \n possible)

Your 2nd one is the closest -- for some reason (likely backwards
compatibility, but it's always bugged me just a little),
*searching* looks for "\n" as a newline, but replacements use
"\r". I think what you want is

:%s/^0\n0$/1\r1/

In this regexp, the "g" flag is superfluous because you're
anchoring to the start and end of the line, so you'll only find
one match.

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

Post a Comment