On 9/19/20 3:13 PM, Tim Chase wrote:
> My assumption was that "aaa" was a meta-regex that matched whatever 
> was needed, including any word-boundaries or other matching/context 
> the OP needed.
That seems like a reasonable assumption.  Thank you for clarifying.
> Depends on what you mean.  There are multiple regex in play:
> 
> - the thing looked for in the g/first/
This first one is what I had in mind when I asked the question.
> - the boundary looked for when looking backwards (empty line or BOF)
> 
> - the boundary looked for when looking forwards (empty line or EOF)
> 
> - 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
> Either way, whatever regex the :s// searches for can capture all (for 
> replacement with "&") or subsets (with "\(…\)" for replacements 
> with "\1" through "\9"), and then use those captured bits in the 
> replacement.
I keep forgetting that & matches the full capture.
> Including if you use the :norm method and capture them in the :g 
> portion.  Here I look for "G" followed by any number of "C"s followed 
> by another "G" and then replace them with a "T" followed by the 
> "C"s we captured, followed by another "T":
> 
>    :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?).
Thank you Tim.  As always you make it easy to learn new things.  :-)
-- 
Grant. . . .
unix || die
-- 
-- 
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/54b71e93-4c02-fb4d-7be4-53854af1aca8%40spamtrap.tnetconsulting.net.
No comments:
Post a Comment