Back

greplace 详解 (vim plugin greplace introduction)

发布时间: 2014-05-27 02:42:00

greplace 是VIM程序员必备技能,可以帮我们批量查询和替换。

例如,查找当前 目录下的所有rb文件中的 'prefix' :

# notice the "." before "-R'
:Gsearch -F 'prefix' . -R  --include=*rb   

  2 # Modify the contents of this buffer and then
  3 # use the ":Greplace" command to merge the changes.
  4 #
  5 app/helpers/target_url_helper.rb:6:      Settings.static_files.folder_prefix, plan.folder_name
  6 app/models/target_url.rb:31:    folder_prefix = Rails.env=='test' ?
  7 app/models/target_url.rb:32:      Settings.static_files.folder_prefix_for_unit_test :

在上面的文件,使用 %s 做完替换后, 
:Greplace 
就可以了。
最后 
:wa 
保存所有的改动。

Back