> Is there any way to write a :%s/// that uses more than nine captures/sub-expressions? At the moment I have to write multiple search and replace commands for each block of nine \1..\9's that I need to capture.
>
If you actually need to capture more than 9 groups, then no, it can't
be done. You might be able to get around it with a nested substitute:
:s/pattern1/\=substitute(submatch
(1,2,3,...,9),'pattern2','replace','')/
Your replace pattern can be built with submatch strings as well as \1
through \9.
However, if you don't need to CAPTURE more than 9, but just GROUP them
(capturing up to 9 of them), that is easily done. Just use \%(...\)
instead of \(...\) and the group won't take up one of your numbered
subexpression slots.
:help substitute()
:help :s\=
:help submatch()
:help /\%(
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment