I\'m looking for the best way to do search-and-replace (with confirmation) across all project files in Vim. By \"project files\" I mean files in the current directory, some
1. :grep (or whatever you use to populate the quickfix window)
2. :cfdo %s///g | update
Step 1 populates the quickfix list with items you want. In this case, it's propagated with search terms you want to change via grep
.
cfdo
runs the command following on each file in the quickfix list. Type :help cfdo
for details.
s/
replaces each term. /g
means replace every occurrence in the file.
| update
saves the file after every replace.
I pieced this together based upon this answer and its comments, but felt it deserved its own answer since it's all in one place.