Clockwork Jam wrote:

> I'm seeing some odd behaviour when passing a submatch to substitute()
> when evaluating a regexp in GVim 7.2. Say I have the following two-
> line file:
> 
> the second line
> appears below
> 
> If I place the cursor at the start of the file and execute the
> following substitution:
> 
> :s/\v(the\s)(\_.*)/\=submatch(1) . submatch(2)
> 
> then it works correctly and I see:
> 
> the second line
> appears below
> 
> However, if I instead execute the following substitution on the same
> pattern:
> 
> s/\v(the\s)(\_.*)/\=substitute(submatch(1),'the','no','') . submatch
> (2)
> 
> then I see only the following line:
> 
> no second line
> 
> In both of these examples, the second submatch spans both lines. But
> in the second example, after calling substitute() with the first
> match, the second match retains only the text that appears on the
> first line. Is this a bug?

Well, either a bug or an unsupported feature.

What happens is that the substitute() call clears the submatches and
sets new ones.

I suppose the submatches should be saved and restored.

-- 
I bought a book on hair loss, but the pages kept falling out.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

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

Raspunde prin e-mail lui