-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I like this idea. It can help by visualizing a complex pattern (while
it's being composed), and it could also be (mis?)used to have multiple
patterns highlighted with different colors in parallel, e.g.
/\(foo\)\|\(bar\)/ would show "foo" in color 1 and "bar" in color 2.
There's definitely demand for that, currently implemented by plugins
(such as my own Mark.vim,
http://www.vim.org/scripts/script.php?script_id=2666) via matchadd().
Regarding the mechanics, I think the biggest challenge lies in the
association of capture group number to highlight group. As your
questions show, this mostly isn't static, but would depend on each
particular pattern. Of course, one could use an off-band mechanism
like separate :hi link Search1 ... | hi link Search2 ... Ex commands
to reconfigure the colors, but that would be cumbersome.
I would suggest to decouple the capture groups from the highlighting,
and instead extend the non-capturing group syntax (\%(...\)) to
optionally supply a color number: \%1(...\) uses Search1, \%2(...\)
uses Search2, and so on. (This is modeled after \%23l, \%23c, ..., and
would not break backwards compatibility.) This allows an in-band
group-to-color mapping, with the downside that captured groups would
have to be explicitly wrapped in a numbered non-capturing group; the
example from above would become a more verbose
/\%1(\(foo\)\)\|\%2(\(bar\)\)/; the benefit would be that another
capture group can be easily added that also uses color 1, or 2, or no
special color at all.
- -- regards, ingo
- --
-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^--
http://ingo-karkat.de/ --
--
https://www.vim.org/account/profile.php?user_id=9713 --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBCAAGBQJdm6leAAoJEA7ziXlAzQ/vKIAH/3xpmi7MdaUIJYmbTQ5Xw7CH
cRJTWLFCR5LEQizS+ZKkGjWSuTifpGNBONOfMtsKWyFi4IMuHDIARCea0C1g+DXS
8S8WjQiaQrg2y9PaLiy9rsDmN4nG5Yh5tMaTiQ7eHYKieqq6wxUkzMOouMjtM0ER
TB9JEJDBzfD/Sm36IOfsAr4f8dycSOShZ19PuQSEziWetubTsQ8Csin9M1X+13NA
0oFfM794940huRIBWTGlfiUA+nNtFni6tdsI7B7Uc5WSjfgZc+7qP0Dm+aAdY+UM
+C8Id9eHDwNG1JdKTXrYK5jclnwBSh2cQM2ElU39Lid0JRLVlQIH8zvxXhVh77o=
=jzvb
-----END PGP SIGNATURE-----