Thanks Christian again, it works!
Best regards,
Leandro.



On Apr 17, 2:50 pm, Christian Brabandt <[email protected]> wrote:
> Hi leandromartinez98!
>
> On Fr, 17 Apr 2009, leandromartinez98 wrote:
>
>
>
>
>
> > Thanks Christian,
>
> > This seems nice. However, I won't be able to remember that, so I'm
> > trying to write a small function, like this:
>
> > function SR(var1,var2)
> >   let search=a:var1
> >   let replace=a:var2
> >   exe ':%s/\V'.escape(search,'/\').'/'.escape(replace,'/\').'/g'
> >   return
> > endfunction
>
> > In such a that
>
> > :call SR(":%s#/\*(.*)\*/> #//\1#g","test")
>
> > should do the substitution. However, I've never wrote a function for
> > Vim, and there is something on the variable definitions that I'm not
> > getting wright. When there are some special characters in the
> > arguments the function does not work.
>
> > Can you (or somebody else) readily perceive what is wrong?
>
> I think, you almost got it right. Instead of using double quotes (")
> use single quotes (') and it should work:
> :call SR(':%s#/\*(.*)\*/> #//\1#g','test')
>
> I think the reason is, that you would otherwise have to quote the
> backslashes (\) in your function call since that is the way, the vim
> parser works. So something like this should also work:
> :call SR(":%s#/\\*(.*)\\*/> #//\\1#g","test")
>
> regards,
> Christian
> --
> :wq!
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to