博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

【VIM】替换命令

Posted on 2011-09-21 21:15  douyamumu  阅读(128)  评论(0)    收藏  举报
To substitute new for the first old in a line: type    :s/old/new
To substitute new for all old on a line: type       :s/old/new/g
To substitute phrases between two line #'s: type       :#,#s/old/new/g
To substitute all occurrences in the file: type        :%s/old/new/g
To ask for confirmation each time add 'c':             :%s/old/new/gc