Global find and replace in Vim

2021 Jul 03

Use the quickfix list.

:grep 'whatever'

Fills the quickfix list with matches.

Be sure and disable anything else which might stomp over the quickfix list, like ALE. Or, use :lgrep which fills the location list, which is scoped to a window.

Acting on the results

Run a command (search and replace, then write) for each file in the quickfix list:

:cfdo %s/whatever/whomstever/g | w