On 03/09/12 13:11, Cesar Romani wrote:
On 09/03/2012 12:43 p.m., Tim Chase wrote:
%s/.*/\='['.toupper(submatch(0)).'](#'.substitute(tolower(submatch(0)),
' ', '-', 'g').')'
>
> -tim
Thanks a lot, it works fine, but if I use it under :execute and try to
convert:
Véase Vaya con Dios
to:
[VAYA CON DIOS](#vaya-con-dios)
there are some problems with quotes, as in:
execute '%s/Véase
\(.*\)/\='['.toupper(submatch(1)).'](#'.substitute(tolower(submatch(1)),
' ', '-', 'g').')'."'"
Is there any reason you're trying to do it with an :exec rather
than just calling it directly? If you must use :exec then you
need to use different quotes around the whole thing. Since my
example uses single-quotes ('), you can wrap the whole thing in
double-quotes for the :exec with the caveat that the "\" needs to
be escaped:
exec
"%s/Véase.*/\\='['.toupper(submatch(0)).']#'.substitute(tolower(submatch(0)),
' ', '-', 'g')"
because the single-quotes close your opening quote that you use
in your exec. Alternatively, you can switch the internal quotes
to double-quotes and then wrap the whole thing in single-quotes
which obviates the need to escape the backslash:
exec
'%s/.*/\="[".toupper(submatch(0))."]#".substitute(tolower(submatch(0)),
" ", "-", "g")'
-tim
--
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