Global substitution of VI commands

Time:2019-12-9

Global substitution of VI commands

WeChat public address:51 yards of rural network
Professional programming Q & a community
www.51manong.com

First open the file you want to operate with the VI command, and then enter:% s / line / line / g
Explain the function of this command:
: used to start an ex command
%Determines the scope of the action, from line 1 to the last line of the file. If you do not enter%, the command will only take effect on the current line. You can also enter specific line numbers 1, 5.
S means this is a replacement operation
/Line / line search and replace text
G represents global, that is, to replace every instance of every row searched. If G is missing, only the first instance of every row that meets the conditions will be replaced