The following command replaces all strings idiots with managers in this article:
:1,$s/idiots/manages/g
Usually we use % in the command to refer to the entire file as the replacement range:
:%s/search/replace/g
The following command specifies replacement only between lines 5 to 15:
:5,15s/dog/cat/g
The following command specifies replacement only between the current line and the end of the file:
:.,$s/dog/cat/g
The following command specifies replacement only within the next 9 lines:
:.,.+8s/dog/cat/g
You can also use specific characters as the replacement range. For example, replace all equal signs (=) in the SQL statement from FROM to the semicolon with inequality signs (<>):
:/FROM/,/;/s/=/<>/g
In visual mode, first select the replacement range, and then enter: to enter command mode, you can use the s command to replace text in the selected range.
- VIM study notes Substitute (may require Anti-GFW)
Oh, maybe I misunderstood the question. .