October 2, 2008
Vim: Substitute in all buffers
To replace all instances of FOO with BAR in one file, you’d do:
:%s/FOO/BAR/g|:up
The pipe | lets you separate multiple commands and :up is like :w but only writes changed buffers.
Now for all open files:
:bufdo :%s/FOO/BAR/g|:up
Roughly translates to: for all open buffers, substitute FOO with BAR and write the changes.
Comments(3)