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 🙂

4 thoughts on “Day 4 – Falling back to the meta-referance

  1. Kirrus Post author

    I did! I’ll try it out once I’ve got Ubuntu installed, but that’s going to come after installing windows. I’ve not got much hope that it’ll work well enough though 🙁

  2. jerichokb

    Apology accepted – I did notice this and forgot to mention, good to see someone pointed out the mistake 🙂
    Keep up the blogging, just don’t stop after a month!

  3. Kirrus Post author

    I noticed it when I re-read the post at some point 🙂

    I’ll try not to stop! I probably won’t post once a day though (unless you really want me to 😉 )

Leave a Reply

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