Here are some ways to replace strings in gvim.
For replacing a string across a file
:%s/<search_string>/<replace_string>/g
To replace in current line
:s/<search_string>/>replace_string>/
To select and replace words from selective lines in vim(In this example want to replace in line 6 to 10 and 14 to 18).
:6,10s/<search_string>/<replace_string>/g | 14,18&&
The :&& command repeats the last substitution with the same
flags. You can supply the additional range(s) to it (and concatenate as
many as you like):
If you have many ranges you can use loops as well.
:for range in split('6,10 14,18')| exe range 's/<search_string>/<replace_string>/g' | endfor
This four options can be used in almost any time that we want select and replace in gvim
No comments:
Post a Comment