On 2020-09-19 16:43, 'Grant Taylor' via vim_use wrote:
> > - the thing looked for in the s// command
>
> This is actually where I was wanting to use the contents of
> g/first/. ;-)
>
>> Using the :norm method, you don't have the two boundary regexen
>> to change the most-recently-used-search, so the regex in the :g
>> can be preserved into the :s// command so you don't have to
>> duplicate it.
>
> If I'm understanding you correctly, the following regex could be
> used:
>
> :g/aaa/?^$\|\%^?,/^$\|\%$/s::bbb:g
The problem is that here you have four different searches. Empty
patterns (in the :s// command) reuse the most recent one:
:g/aaa/ ?^$\|\%^? , /^$\|\%$/ s::bbb:g
1 2 3 4
The most-recent-search gets set to "aaa" (1), then set to "^$\|\%^"
(2), then set to "^$\|\%$" (3), leaving (3) as the most-recent for
reuse in the :s command at (4) which isn't what you want. You could
simplify in the opposite direction, making your pattern *any*
paragraph-boundary and reusing it instead:
:g/aaa/ ?^$\|\%^\|\%$? , // s:aaa:bbb:g
1 2 3
(reusing #2 at #3)
Which is also why it *does* work for the :norm version because that
one doesn't tromp on the most-recent-search like the
range-relative-to-each-match version does. Similarly, if your
relative range didn't involve searching such as
:g/aaaa/-3,+2s::bbbb:g
it would work.
> > :g/G\(C*\)G/norm vip:s//T\1T/g^V^M
>
> This seems like the typical subset mentioned above used in
> conjunction with the "last search pattern" (nomenclature?).
For more on this (though its prose could use a little reworking for
additional clarity)
:help last-pattern
> Thank you Tim. As always you make it easy to learn new things. :-)
I find it fun, so there's that. :-)
-tim
--
--
You received this message from the "vim_use" 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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200919180851.68a1ee23%40bigbox.attlocal.net.
No comments:
Post a Comment