Hi Ingo!
On Di, 21 Dez 2010, Ingo Karkat wrote:
> On 20-Dec-2010 23:26, Christian Brabandt wrote:
> > Hi Bram,
> > when working with csv-files, I have often wished for more than 10
> > capturing groups. So here is a patch, that allows 99 capturing groups in
> > the replacement part. This uses the perl-like syntax ${1} until ${99}
> > for the capturing groups in the replacement part. If there does not
> > exist a capturing group, this will resolve to the empty string.
> >
> > I have tested it locally and it works for me[1]. This obviously needs to
> > be very well tested, before included.
> >
> > [1] running make test as well as trying several different :s commands.
> >
> > regards,
> > Christian
>
> I don't like the fact that this introduces another character /
> substring that needs to be escaped in the replacement text, thus
> breaking backward compatibility and making scripting more difficult.
> So far, only "\" (and "&" and "~" depending on 'magic', cp. :help
> sub-replace-special) need to be escaped.
Yes there is a certain possibility, that you use something like ${1} to
insert that part literally. But unfortunately, this has to be done. I
understand that this breaks backwards-compatibility, so this makes only
sense with a new vim version.
> Since that many capturing groups are rarely used (but I agree, could
> sometimes be useful), how about just making them available through
> submatch({nr}), as in:
> :s/{pat}/\=submatch(99)/
Possible, but I don't like that. Especially if you use many capturing
groups, I'd like to avoid using string-expressions whenever possible as
the quoting can get nasty.
> This would keep compatibility. Alternatively, couldn't something
> starting with a backslash be used, for example \{99}?
This might still break backward compatibility. And personally, I like
the ${1} syntax better (as this is used in Perl for example).
> -- regards, ingo
Thanks for your comments.
regards,
Christian
--
You received this message from the "vim_dev" 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