Okay so there are a series of files that need to be updated and fixed. You can grep the evil pattern and then send the list of files affected to vim for a quick fix.
Use Grep to find files and pass to Vim
grep -l "messed up pattern" */*| vim -
grep -l <pattern> /
this searches for the pattern and lists (-l) the files affected
| vim -
the output of grep is sent to a vim buffer
Open each file individually with gf (option a)
- First must run
:set hiddento allow buffer with file names to be buried
- Next put cursor over filename and type
gf. Vim will open that file in a new buffer.
- When you are finished editing file, type
C-oto return to file list.
Run :bufdo %s/// to updated all files at once (option b)
You first must run
:set hidden to allow the buffer with file names to be buried
:bufdo %s/messed up pattern/good happy sub/ge | update
bufdoruns a command on all open buffers.
%s/old/new/geis the substitution command bufdo will run on all buffers.
| updatewill write the changes to all buffers that have changed.