Thursday, January 27, 2011

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

Oliver Rath wrote:
> Maybe its easier, to reduce \\ to \ and expand THEN all \ to \\.
>
Oliver's solution is probably easiest, and therefore the best; however,
the following would also do the trick:

:%s/\%(^\|[^\\]\)\zs\\\ze\%([^\\]\|$\)/\\\\/g

Logically, this means: match a \ so long as:
* it isn't preceded by a \ (or is at the beginning of line) AND
* if it isn't followed by a \ (or is at the end of line).

Regards,
Chip Campbell

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