Interactive find and Replace across lots of files

Yet another problem that caused me endless headaches until I found Vim: how to interactively find and replace across lots of files? Perl doesn't work, because I want to examine changes before I make them to make sure I'm not doing something harmful.

The easiest way to do this is with the Vim ':argdo' command, which does something to each file in the file argument list. In this demo, I change all the instances of 'M_simulation_record_variable' to 'M_sim_rec'. You'll notice that it takes a while to scan because I have over 200 files.

  1. I yank the variable into the buffer with 'yW'.
  2. I enter the argdo command in the command buffer.
  3. I interactively change all the instances except one, which I leave alone.