On 2020-09-19 12:02, Igor wrote: > I specially like bellow solution, that I have tested > and it works fine. > > :g/^XXX/.,/^$/s:aaa:bbb:g > > Just one question, why is there a "." character in command? > If I understand it correctly, a "." character means the line where > cursor is, > and with the range used in global command, "current line" (the dot) > is the first line in range and that is the line with "XXX". If we > simplify, we can omitte the "." character and we get: > > :g/^XXX/,/^$/s:aaa:bbb:g
Correct. > The above command means: > - search for the line where at the beginning of the line is XXX > string, and this becomes beginning of the range, > - then search empty line "^$" that is actually end of paragraph, > and this becomes ending of range, > - then execute search and replace command within (and including) > beginning and ending of range. Exactly! Once you start seeing this pattern, it's hard to unsee and you find yourself using this regularly :-D -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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200919142838.58be0585%40bigbox.attlocal.net.
