Latest entries

28 Aug 2011
23 Aug 2011
16 Aug 2011
7 Aug 2011

@getintogaming Maybe "Masters of Doom"? http://t.co/4AE4agl About id software in its heyday.@twitter

0 comments

5 Aug 2011

Leeds crüe: Join us for a spot of national shopkeeping with @danbentley @cmbentley @phoenixrises @catnamedeaster and myself tonight.@twitter

0 comments

4 Aug 2011

@csswizardry Didn't know the 2nd one existed. Cheers, looks interesting.@twitter

0 comments

30 Jul 2011

Toggling relative line-numbering in Vim

With the recent release of Lion, OS X users get access to the latest version of Vim. That includes the new relative line-numbering feature which looks particularly useful given Vim's many line-wise operations (see :help relativenumber for details).

However, it might not be something you want on all the time. Absolute line-numbering is useful in debugging and for providing context, and relative line-numbering could be slightly distracting given that it changes as you move around. So, you might want to toggle between the two modes.

Toggling between absolute and relative isn't as simple as :set relativenumber! though, because norelativenumber just turns off line-numbering rather than falling back to number.

So here's one way of handling things. First set your default numbering:

if exists('+relativenumber')
    set relativenumber
else
    set number
endif

Add a function to toggle between the two modes:

function! ToggleNumbering()
    if exists("+relativenumber")
        if &relativenumber
            set number
        else
            set relativenumber
        endif
    else
        set number!
    endif
endfunc

If the option isn't available, e.g. you're on a version earlier than 7.3, it falls back to toggling line-numbering on or off. If you were so inclined, you could do a version that cycled between the 3 possible states (off, absolute and relative), but I prefer it like this.

Finally, map a keyboard shortcut to trigger the function:

noremap <leader>n :call ToggleNumbering()<cr>

I use <leader> mappings a lot for my own personal shortcuts, but a lot of people seem to prefer the function keys. You can replace <leader>n with <f12> or whatever if that includes you.

Paste that lot into your .vimrc and continue on your merry way.

0 comments

21 Jul 2011

@JoeTheDough A bold statement. I counter with Burts Bloody Mary, Brannigans Smoked Ham & Pickle, and Walkers Worcester Sauce.@twitter

0 comments

14 Jul 2011

@offmessage @mrben @natblundell That's what example.com's for.@twitter

0 comments

11 Jul 2011

@offmessage We got left a pigeon print some years back, complete with a perfect little bird turd at the bottom. It was practically art.@twitter

0 comments

10 Jul 2011

@winjer @bne @JoeTheDough I saw them at a christmas ATP in Camber Sands in 2005. Was worth it despite the cold.@twitter

0 comments

7 Jul 2011

@nofunnyname Is that the M&S snack pack thing? I always leave the beetroot one. Tastes like soil.@twitter

0 comments

4 Jul 2011

@mrben_ Worst. Shortcut. Ever.@twitter

0 comments

11 Jun 2011
1 Jun 2011

@csswizardry @danbentley "They talk by flapping their meat at each other." http://baetzler.de/humor/meatbeings.html@twitter

0 comments

31 May 2011

@iamgaz Not sure that's true across the board. I hear Catherine and Demon's Souls are both genuinely hardcore.@twitter

0 comments

29 May 2011

It's alive!

Wheee, I thought this thing was permanently out of commission thanks to circumstances beyond my control, but it was fixable after all. I was this close to replacing it with one of those single-page placeholder sites.

Anyway. Fear ye, fear ye. I have returned.

0 comments

15 May 2011

@offmessage Not Puerto Rico. But we have San Juan (a trimmed down card game version of it by the same guy) which is great.@twitter

0 comments

12 May 2011

@offmessage as @bne says pushState. Or specifically: https://github.com/defunkt/jquery-pjax@twitter

0 comments

8 Apr 2011

← Archived entries by month

Where am I?

The personal site of Matthew Tarbit, a seasoned web developer holed-up in a hideaway somewhere in the depths of Leeds, England.


Reading

See all books & authors in the library.

by
added 7 Aug 2011