I found out about Vim\'s substitute command...
:%s/replaceme/replacement/gi
And vimgrep...
:vimgrep /findme/gj project/**/*.r
To answer the original question of combining vimgrep and substitute:
:vimgrep /pattern/ ./**/files # results go to quickfix list
:set autowrite # auto-save when changing buffers
:silent! cdo %s/replaceme/replacement/gic # cdo draws filenames from quickfix list
:set noautowrite
Leave out the c
of gic
if you don't want to confirm each replacement (in which case you could also use find
and sed
as suggested by @LaurenceGonsalves).