On Nov 23, 6:03 am, "Ricky Wu" <[email protected]> wrote:
> Hi all
>
> I'm confused about substitute function:
>
> "String#CHAR" transfer to "String\#CHAR", but why here need four "\"?

Because you've used double quotes instead of single quotes, the
backslash must be escaped twice: once for the double quote and again
for the replacement.

:help expr-string
:help literal-string
:help s/\\

You could use 2 backslashes if you used a literal string (single
quotes): e.g.,
:echo substitute("String#CHAR","#", '\\#',"g")

Brett Stahlman

>
> :echo substitute("String#CHAR","#","\\\\#","g")  I got:
>
> String\#CHAR
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to