【vim】替换(一)

来源:互联网 发布:幼儿园网络培训意义 编辑:程序博客网 时间:2024/06/06 00:03

:s/old/new/

This changes the first occurrence of the pattern old to new on the current line


:s/old/new/g

The g option affects each pattern on a line; don’t
confuse it with the :g command, which affects each line of a file


:1,30s/his/the/gc

Confirming Substitutions(确认是否替换)


:g/pattern/s/old/new/g

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. 

原创粉丝点击