I read this description of a different example, substitute command and it was very helpful, but I'm still not fully certain how to interpret the commands in :g /start1/.,/start2/-1 move /end/-1
. It is supposed to be something that has the text start1
on some line, followed by text, followed by a line that contains start2
, followed by a line that has end
. In outline, like this:
texttexttext
.Rh start1
.Rf some text
some more
...
.Rh start2
more text
...
.Rh end
textytextytext
The search-and-replace command is supposed to take everything from .Rh start1
to just before .Rh start2
and move it between .Rh end
and textytextytext
.
The way I read it so far, :g /start1/...
says to globally search for start1
and do ...
. Now since the ...
is .,/start2/-1 move /end/-1
what does this mean? I take the .
to be a regex for "any character", which is just followed by a comma. Is Vim searching for that character-comma combination? Or is it replacing the start1 line with it?