Home Random Sh17cast Forums

Search and Replace using VIM

Sunday, November 1, 2009

I always forget little things like this.       Today I changed the dyndns hostname I’ve been using on a server, and needed to update my Apache vhost .conf file to reflect the new domain.      There’s only about 10-15 virtual hosts in this file, but I still didn’t want to manually edit it.    I’m lazy.

vim 90_bac.supercoolname.tld.conf

Once you’re in vim, it’s super-easy to do a find and replace.     This is the command I ran:


%s tells vim to search through the entire file.

/g tells vim to replace every instance of bac.supercoolname.tld with bac.evenbettername.tld

There’s a ton of other useful stuff you can do with regular expressions, but this is something I forget a lot when I don’t use it frequently.

Discover and Share
posted by johntash at 1:14 pm  

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

23 queries. 0.102 seconds.
Copyright © 2007-2010 http://www.thesh17.com