Quiet Mumblings

Tuesday, September 05, 2006

Colours in vim on PuTTY (and mice too!)

OK - this is both geeky and non-geeky at the same time. Its geeky because I actually spent time trying (and succeeding) to find out how to do it, and its non-geeky because I know so little about vim its embarrassing.

Anyway - the life threatening dilemma that I was facing this week was how on earth to get syntax highlighting to work in vim over PuTTY. I've been using vim over PuTTY without syntax highlighting for so long that I just assumed it wasn't possible, but I was enjoying it so much in gVim on my desktop that I figured it must be worth a look around. A quick seach found that it was... But a longer search and I still had no idea what I was doing wrong. It was beginning to frustrate me.

Unfortunately the reason why I couldn't find my answer was because it was so obvious. So for those as dumb as me, repeat this vim command:

:syntax on


Yes. Its that simple. Your screen should now have lit up with a load of beautiful syntax highlighted code (providing you're looking at code, of course). If it doesn't then there's all sorts of complex stuff you can do, but I stopped there thankfully. The next command is to set your preferred colour scheme:

:color torte


And of course replace torte with murphy or whatever your favourite choice is. This is where I went "eh?" a bit - because of the pallette limitations of PuTTY and SSH it appears that the colour schemes look quite different over PuTTY to the normal gVim schemes. This is not a problem for me - I just played until I found a new one I like, but again a bit more digging and you can find complex ways to approximate the original versions if you *really* like them that much!

Finally, and this was an added bonus, you can use your mouse in vim in PuTTY! Yes! Wow! (Or Doh! if you knew that already). To do this the command is:

:set mouse=nv


Why "nv" you may ask? Well, you can set it simply to "o" in which case it will work in all modes, but then when you right click in PuTTY instead of doing PuTTY's usual paste action it will just do a vim right click. For me copying and pasting between the PuTTY window and other windows is vital - so the "nv" command turns on the vim mouse only in command and visual mode, but not in edit mode. Smart, eh?! I worked that bit out for myself at least! :-)

Geekiness of the day ends here...

1 Comments:

  • A correction to one point on this post. To set the mouse to work in all modes, you would use

    :set mouse=a

    (not 'mouse=o' as the post says).

    By Anonymous Anonymous, at 8:22 pm  

Post a Comment

<< Home