Fellow tuxies,

I'm frequently faced with the problem of replacing a string across an entire directory. For the mindless tasks, I've seen solutions ranging from general usage string manipulation tools (perl, sed) to something as specific as rpl.

However, because I'm a programmer, this sometimes involves replacements that cannot be done blindly. Asking the user for a confirmation on each replacement is viable here. And so I've compiled a small line that does this for you.

For the purposes of this demonstration, let's say I want to replace all occurrences within my current directory (a project that makes use of the 'automobile' variable which should be shortened to 'car').

I'd run this command:

Code:
vim -c "argdo %s/automobile/car/gc | w" `grep -lR automobile .`
The grep command would give me a list of files in which 'automobile' occurs. This is way more efficient than having vim open every file in the project, but terribly hackish (and not really efficient, either, if there are many matches).

At first when I looked into this problem I was looking for utilities that would show the current context of the line, displaying up to 80 characters of context around it. When I discovered the vim solution, however, I realised the convenience of being able to see the real context of word within the application scope, with multiple lines above and below. Now that I've gotten picky I'd sort of like to keep that functionality.

The Question
Is there a better way to do this? By better, I mean more efficient, simpler to write out (without making a shell script) or more verbose. Please post any ideas for improvement.

Regards,
Cloakey