[lug] Little vim trick, editing multiple files
tkil at scrye.com
Wed Nov 30 18:59:06 MST 2005
>>>>> "Andrew" == Andrew Diederich <andrewdied at gmail.com> writes:
Andrew> I needed to edit a bunch of files, changing /old/path to
Andrew> /new/path. I knew there was a way to do it in vim, but
Andrew> couldn't remember offhand.
I tend to reach for perl for this sort of thing:
perl -i~ -pwe 's:/old/path:/new/path:g' files...
Quick version of the arguments:
-i~ edit "in-place", create backup if changed with "~" suffix
-p print every line after applying the script
-w print warnings
-e script is given on command line in next arg, not in first file
More information about the LUG