Tuesday, April 24, 2012

Re: questions about submatch()

On Tuesday, April 24, 2012 10:01:35 AM UTC+2, JohnBeckett wrote:
> rameo wrote:
> > If I use submatch like this:
> > :%s/'pattern'/\=MyFunction(submatch())/g
>
> That gives:
> E119: Not enough arguments for function: submatch
> E116: Invalid arguments for function MyFunction(submatch())
>
> > I would like to confirm (with a "c" flag) all single
> > substitutions but the "c" flag at the end of the substitution
> > command (:%s/'pattern'/\=MyFunction(submatch())/gc) doesn't work.
>
> The following works on my system:
>
> function! MyFunction(m)
> let x = len(a:m)
> return x
> endfunction
> %s/'pattern'/\=MyFunction(submatch(0))/gc
>
> Testing on following gave a confirm for each change.
>
> 'pattern' hello 'pattern' hello 'pattern' hello
>
> John

Thank you John.
I resolved it :)

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

No comments:

Post a Comment