Daily Archives: November 4, 2008

Day 4 – Falling back to the meta-referance

Last night I posted on twitter that I was struggling to find stuff to post about. jkblacker (Not bassets, sorry Josh!) suggested that I post about how I’m finding it hard to find stuff to post about… so here it is 😉

Not exactly the most spectacular day 4, especially since I’ve got 26 left to go, but we’ll see what happens.

Parts for my new computer started arriving today. I’d hoped that it would all arrive, but unfortunately not. So, right now I’ve got RAM, the PSU, Motherboard, CPU cooler and a copy of Windows. (Yes, I know, horrible, but I’m building a gaming machine, wine isn’t there yet, and Linux hasn’t reached critical mass 🙁 )

Sporadically over the past week or so, I’ve been trying to use search and replace in vi/vim. Finally got it drummed into my head! Here’s the syntax for single item search and replace:

:%s/OLDSTRING/NEWSTRING/

If you want to replace every item in a document, then add “g” to the very end. “g” in this context means “greedy” – i.e. replace everything. (Thanks JPE – I did learn it after all!)

This is the same sort of syntax as usable in the command line tool “sed”. For example, if you wanted to replace a space in a file with a comma, then you’d do:

sed 's/ /,/g' oldfile > newfile

I’m sure there’s a better way to specify that syntax… please feel free to comment 🙂