Wednesday, January 26, 2011

Re: How to replace "\" to "\\"

Am 26.01.2011 07:34, schrieb Wayne Young:
> Thanks very much. The second works!
> I am still wondering how it work. It seems to replace the "
> \%(\\\)\@<!\\\$(\\\)\@! " part to "\\\\". Would you help to explain the
> meaning of the replaced part?

What about '\\\', the given substitute will not turn it into '\\\\'.

Better alternatives (all three supposed to do the same):
:%s/\\\@<!\%(\\\\\)*\\\\\@!/\\&/g
:%s/\\\@<!\%(\%(\\\\\)*\)\@>\\/\\&/g
:%s/\\\\\=/\\\\/g

The last one is short, but will not report a useful number of changes.

--
Andy

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