Argdo me, baby!

I’ve been a Vim user for a long time, and the trouble with being a long-term Vim user is that it’s frequently not too different from being a short-term Vim user. It’s an incredibly powerful text editor with an incredibly steep learning curve, and the trouble is that a lot of us, once we know enough to feel the massive Vim advantage, just never really get around to doing all the truly advanced things.

Like, for example, search-and-replace across multiple files.

Honestly, Vim has added at least 14 hours to my life over the years with all the time it’s saved me on search-and-replace. But even though I knew it could do this across multiple files – have known for almost a year now, actually – I never bothered to go and learn it.

Fortunately, Ibrahim Ahmed‘s got the goods. Apparently the trick is that you pass all your related filenames to args:

:args *shtml

Annd then you process them all through argdo, careful to pipe it to update so that all the files get saved. (Yes, undo seems to work across files for this command as well!)

:argdo %s/one/two/g | update

This was a huge help today adding a link to the header logo of every page in a conference page I’m making for the Lingusitics Department. Yes, yes, I know I’m supposed to have done this with server side includes, or Javascript, or to have done the whole project in Rails to begin with. Honestly, it’s not such a large-scale venture that I feel the need to get it absolutely perfect.

The Department Website itself, on the other hand, could look a lot more professional. One of my (serious) goals for this semester – since I think it will probably be the last semester I am webmaster for IU’s Linguistics Department (moving on to graduate soon).

Anyway, thanks, Ibrahim!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>