Totally awesome software for iPhone and OS X

Tuesday, September 2, 2008

Pimp your (Mac)Vim

One of the truly great productivity enhancing pieces of software everyone should play with is Vim.

Currently I'm using MacVim as my 'IDE' of choice and even when it's not my choice (e.g. I'm using IntelliJ for one project) I have MacVim set up as an external editor and 9/10 open and edit files in it. It's like TextMate but good (hee hee).

I thought I'd share here a few of my favourite plugins.

1. NERDTree

Probably nothing new to regular Vim users, but NERDTree gives you that full on IDE style file browser in a separate pane, like this.



Once installed simply type :NERDTree /path/to/whatever and it'll open at the specified directory.

The beauty of this approach is that you can navigate around using the standard Vi movement keys (h,j,k,l) and open files in a new buffer (on the right) using 'o' (using 'o' on a directory opens or closes it depending on it's current state). You can also use the usual search features to quickly find files and directories (way quicker than teh puny scroll wheel). Oh, and you can switch back and forth between windows using Ctrl-w Ctrl-w.

Why is that beautiful? Well, your hands no longer need to leave the keyboard and reach for the mouse and after a short learning curve you earn 10 productivity points. Well done!

You can download NERDTree here.

2. Buffer Explorer

Now that you're awesome at opening and working with hundreds of files (just like a real IDE) you'll probably want an easy way to switch between them. Vim does let you do this quite easily using e.g. :b 2 (switch to buffer 2) and :buffers to list open buffers, but that's not good enough for us Vim pimps.

So I'd suggest Buffer Explorer. With Buffer Explorer in place you simply need to type \be to get a navigable (as in searchable, uses standard vi movement keys etc. etc.) list of all your open buffers.



Hit enter to switch to the currently highlighted one. Easy.

You can download Buffer Explorer here.

3. Browser

'NOFIRETRUCKINGWAY!' I hear you scream. But yes. Yes, you can have limited web browsing capabilities in Vim. It's arguable wether most browsing is actually productive most of the time, but I find it useful to be able to reference Suns javadoc quickly on occasion. Also, having a browser that strips out images and javascript and 99% of the web experience BUT gets you straight to the data is a good thing.

There's a couple of browsers available for Vim, I chose one based on Lynx as it doesn't appear that MacVim was built with the embedded perl extensions and I couldn't really be bothered to tinker too much. So you'll need Lynx. I got this via. MacPorts, all fairly straight forward (sudo port install lynx)...

So now in command mode I can type e.g. :WebBrowser www.reddit.com and catch up on the latest interlinks, kind of...



Ok, it's not beautiful, but it's functional and quicker than scrobbling about looking for Safari amongst the sea of desktop flotsam.

You can download browser.vim from here.

Installing Plugins.


Because MacVim comes packaged as a .app the only way I've found to install these plugins is to copy them into the App bundle itself. You can either do this in Finder (using Show Package Contents) or from the command line. Either way you need to put them in this directory :

/Applications/MacVim.app/Contents/Resources/vim/runtime/plugin

© 2007 Wired Up And Fired Up