On 09/03/2012 02:34 p.m., Tim Chase wrote:
> 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?

Because I'm using it inside a function

> 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")'

I think, with the parentheses it should be:

exec '%s/.*/\="[".toupper(submatch(0))."](#".substitute(tolower(submatch(0)), " ", "-", "g").")"'

Best regards,

--
Cesar

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

Reply via email to