vi editor to find and replace method
1. Find
: / current line down to find
:? The current line-up looking
to continue to look after the find
in the same direction n
in the opposite direction N
2. Replace
Format: range s / source / target / g
explanation:
the Range represents the range to search for
"s" indicates the meaning of the letter search, this is not essential;
Source represents a string to be searched,
target represents the string to be replaced,
G represents eligible for replacement of all of the string;
to the value ranges which are as follows:
1) all of the rows in%;
2) represents a current line;.
3) $ last line;
4) can be expressed in specific numbers of specific row, such as 10, 20;
example:
: s / str1 / str2 / string line to be replaced in str2 str1 first occurrence
: s / str1 / str2 / g with the line to be replaced in str2 str1 all strings appear
:., $ s / str1 / str2 / g text string str2 replace all the current line to the end of the string str1 appear
: 1, $ s / str1 / str2 / g used in str2 replace all text strings appearing str1
10 years ago, the article _ vi editor to find and replace method
Guess you like
Origin www.cnblogs.com/hshy/p/10927693.html
Recommended
Ranking