Replacing text in multiple files is really easy with Vim. However, it’s not quite popular feature and a lot of people don’t know that such exists. In this post we will show you a few tricks that will get the job done.
If you want to replace
params in the current buffer, you can do it by executing the following command:
However, if the substitution has to be made across all files with extension
.rb in a directory, you will have to use
Also you can put the
c flag, which will ask for confirmation before each change. Pretty neat, huh?
The limitation of
argdo is that it won’t search the supplied directory recursively, but you can use the awesome DirDo.vim plugin to accomplish it:
1 2 3
Finally, the unix tools
awk are always an option that you might consider handy.