1. Introduction
When using VI, something needs to replace the string
The basic substitution
: s/vivian/sky/replaces current line first Vivian for Sky
: S/vivian/sky/g replaces current line all Vivian for Sky
: N, $s/vivian/sky/replaces the first n line to the top Vivian for each line in the last line of Sky
: N, $s/vivian/sky/g replaces the first n line to each line in the last line all Vivian for Sky
(n is a number, if N is., which means starting from the current line to the last line)
:%s/vivian/sky/(equivalent to: g/vivian/s//sky/) replaces the first Vivian of each line as Sky
:%s/vivian/sky/g (equivalent to: g/vivian/s//sky/g) replaces all Vivian in each row as Sky
2. Use #或 + as separator
You can use the #或 + as the separator, which appears in the middle/not as a separator
: s#vivian/#sky/# Replace the first vivian/of the current line as sky/
:%s+/oradata/apras/+/user01/apras1+ (using + to replace/):/oradata/apras/replaced with/user01/apras1/
Section excerpt from http://blog.csdn.net/aldenphy/article/details/4019486