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.

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

This would keep compatibility. Alternatively, couldn't something starting with a
backslash be used, for example \{99}?

-- regards, ingo

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

Raspunde prin e-mail lui