The substitute command, one range at a time
The substitute command, one range at a time
Answer
:s/old/new/ :s/old/new/g :1,$s/old/new/g :%s/\<log\>/trace/gc
Escalate the range, not the strings. Line 1 changes the first match on the current line only; line 2 changes every match on that line; line 3 covers line 1 through the last line (`$`); line 4 is the vim shorthand `%` for the whole file, matching `log` only as a whole word (`\<` and `\>`) and asking for confirmation at each match (`c`).
Sarwar & Koretsky 3e ch3 §3.1–3.4