John Beckett wrote:
> epanda wrote:
>> I have done a func that I call on that way :
>>
>> :%s/myPattern/\=MY_FUNC(submatch(4),submatch(5),submatch(3),submatch
>> (2))/
>>
>> I would like to not substitute the pattern, just analyse each line.
> 
> Add the n flag: :%s/.../.../n

That was my first thought too, but it looks like the replacement 
portion isn't evaluated if you use the /n flag.  I tried the 
following on some sample text:

   :let x=[] | %s/\w\+/\=add(x, submatch(0))/gn

and x was still empty at the end of it (it was populated when the 
/n flag wasn't used).  This suggests that Epanda's MY_FUNC() 
won't get called with the /n flag.  To get evaluation, I had to 
do something like

   :%s/myPattern/\=MyFunc(...)/g | u

to let it do the replacements and then undo them.  This does 
require an appropriate (non-zero) 'undolevels' setting.

-tim





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

Reply via email to