Replace across files
There are many plugins for handling find/and replace across files in Vim, but sometimes only a native way will do. While many people prefer to do substitution from their command line outside of Vim, I often reach for this native, no-plugin way to substitute text across files: the args list.
First, you populate the args list with the list of files you want to search across. For example:
:args path/to/file/glob/*.js
Next, you perform the substitution across those files:
:argdo %s/pattern/replacement/g
Finally, save all the files:
:argdo update
Checkout the gif below where I perform these 3 steps to change all the references of vim
to emacs
. The gif is too annoying to watch, I’ve uploaded a video version to our YouTube channel.
