I found out about Vim\'s substitute command...
:%s/replaceme/replacement/gi
And vimgrep...
:vimgrep /findme/gj project/**/*.r
You could run vimgrep then record a macro that goes to each line in the vimgrep output and does the replace, something like this: (dont type in the # comments!)
:set autowrite #automatically save the file when we change buffers
:vimgrep /pattern/ ./**/files
qa #start recording macro in register a
:s/pattern/replace/g #replace on the current line
:cnext #go to next matching line
q #stop recording
10000@a #repeat the macro 10000 times, or until stopped by
#an "error" such as reaching the end of the list
:set noautowrite
I have not tested it, so it may need a little tweaking - test it on some files that you dont mind getting messed up first.
The advantage of this over sed is that Vim regex are more powerful, and you can add the c option to :s to verify each replacement.
Edit: I modified my original post since it was wrong. I was using :1vimgrep to find the first match in each file, but I misread the docs - it only finds one match across all files.