On 21-Dec-2010 09:51, Christian Brabandt wrote:
> Hi Ingo!
>
> On Di, 21 Dez 2010, Ingo Karkat wrote:
>
> 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.
I don't think people will write a substitution involving more than 9 capturing
groups on the fly in their daily use, so this feature would be almost
exclusively used by mappings and scripts that are written once and run many
times. That's why I would favor a trade-off that keeps full compatibility and
makes it somewhat harder for plugin authors.
Maybe it would help if you shared your use case with CSV files. (But then, this
could also move the discussion into "wait, you can already do this via ...")
>> 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).
Yes, but Perl also uses the "$" sigil already for variable interpolation in
strings and has corresponding escaping rules; Vim does not.
The help mentions that Vim reserves all unused backslash sequences:
\x where x is any character not mentioned above:
Reserved for future expansion
Let's see what others think of this!
-- 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