Saturday, May 22, 2010

Replacements with return

I'm trying do replace strings that contain return characters. For
example,
I would like to change:

----

0
0
----


to

----

1
1

---

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)
and variations of that using ^V+Return, ^V+^M.

None of the combinations above give the correct result. For
instance, :g/\n0\n/s//\n1\n/g results in:

-----
^@1^@0
-----

And :g/\n0\n/s//\r1\r/g

results in:

----

1
0

----

I'm not getting the logic. Is there any symbol which represents
the return character uniquely and acts in search/replace as a
normal character?

Thanks.
Leandro.

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