Wednesday, December 30, 2009

How escape chars in strings in functions

Hi all,

Vim 7.2 on Linux. I'm having problems getting my head around how to
escape chars in a string used within a function. BTW, I'm a programmer
and experienced vim user, but new to vim scripting.

I want to insert some html tags at current cursor location, not the next
line.

String to insert:
<a href="#footnote1" id="back1">[1]</a>

Based on strings surrounded by '' not being interpreted, as per the help,
I was going to use:
put='<a href="#footnote1" id="back1">[1]</a>'

but it bombs out at the '=' after href. The string *is* being interpreted.

However, if I use the string in a variable and append it using exe:
let footnote = '<a href="#footnote1" id="back1">[1]</a>"
exe "normal a" . footnote

it works fine. Clearly I don't understand when escapes are needed and why
exe works but put doesn't.

Can anyone point me to where in the manual you can find out about these
things?

Thanks,
--
NickC


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment