1. :g/pattern/s/old/new
The first g tells the command to operate on all lines of a file. pattern identifies the lines
on which a substitution is to take place. On those lines containing pattern, ex is to
substitute (s) for old the characters
old could be regular expression
2. :%s/old/new/g
% indentifies all lines
s substitudes command
"old" could be regular expression
本文介绍了Vim编辑器中用于替换字符串的两种命令。第一种是g/pattern/s/old/new,该命令针对文件中包含特定模式的所有行进行替换操作。第二种是%s/old/new/g,作用于全文所有行,将old替换成new,并在整个文件范围内进行全局替换。
159

被折叠的 条评论
为什么被折叠?



