Re: Strange behaviour in %s/.../\=.../
Gerald Lai schrieb:
>it does work in this case where nr2char() only returns one character,
> On Fri, 24 Feb 2006, J?rgen Kr?mer wrote:
> > originally I had a file with names of the ASCII control codes, each in
> > one line, and I wanted to make a table with the decimal and hexadecimal
> > values and the common control+letter description. For this I used the
> > following command (all in one line)
> > :%s/^/\=StringOfChar(' ', (line('.') <= 10)) . (line('.') - 1) . ' | $' . toupper(Hex(line('.') - 1)) . ' | ^' . nr2char(64 + line('.') - 1) . ' |'/
> > which failed when it came to writing '^\'.
> Would adding an extra backslash after ^ (but before the single-quote)
> help? It should be quite safe to escape every sequence. Something like:
> works for me to produce <\>
but in the more general case with a function returning a longer string
the only way is to wrap the function with a call to escape(..., '\').
And I find this quite cumbersome -- and a little bit illogical, because
a backslash normally only has a special meaning inside VIM if you enter
it directly, not when it is returned by a function.
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)