Shortly after getting my MacBook Pro, I realized that I had to change the way I used text editors. I wound up using the fn key so often that I started wearing a callous on my left pinky finger. And as a regular emacs user, all of the CTRL-this and CTRL-that was wearing thin fast (and that’s with the caps lock key mapped to CTRL like God intended).
At OSCON this year, I attended Damian Conway’s Vim tutorial. It was basically a 3 hour demo / Vim love-fest. I was amazed at how quickly he could navigate and edit text using vim. What really attracted me was his emphasis on efficiency – using the minimum number of keystrokes to accomplish the task.
If you’ve never used vi/vim, you need to realize that vim is a modal editor – when not in insert mode, all keys are available as command keys. This effectively eliminates most of the awkward CTRL- META- keystrokes from other editors.
So I’ve been slowly making the switch to vim, and last week I decided to speed up my conversion by forcing myself to edit all of my Ruby and C++ code using vim. It was slow at first, but I gradually picked up speed over the week. I don’t think I’m as fast as emacs in all scenarios, but in some common ones (e.g. change the name of a variable) I’m definitely faster than emacs.

For my C++ code, I decided to try out ViEmu, a vim emulator for Visual Studio. This let me use vim key bindings within Visual Studio. A word of warning – you’ll need to manually remove some of the default bindings to CTRL-this and CTRL-that in VS 2005 if you want the corresponding vim key bindings to work. Apparently this will be fixed in a future release – this will make the out-of-box experience much better.
I used Jonathan McPherson’s Efficient Editing with Vim page a lot during my transition. This document cuts to the chase and does a really good job of telling you what commands are really useful (and there are a lot of commands in vim).
For a more comprehensive resource, I’m using Steve Oualline’s vim book. It’s a bit dated (it’s current as of Vim 5.7), but most of what I’m interested in hasn’t changed all that much. But the price is certainly right. Thanks, Steve!
I use the vim-ruby configuration files for setting up vim to work with Ruby. The syntax coloring and code formatting features work great. I’ve created a coloring scheme that’s based on the Vibrant Ink by Justin Palmer. This is what it looks like:
Here’s my .vimrc code that defines the color scheme:
highlight Normal guifg=White guibg=Black
highlight Cursor guifg=Black guibg=Yellow
highlight Keyword guifg=#FF6600
highlight Define guifg=#FF6600
highlight Comment guifg=#9933CC
highlight Type guifg=White gui=NONE
highlight rubySymbol guifg=#339999 gui=NONE
highlight Identifier guifg=White gui=NONE
highlight rubyStringDelimiter guifg=#66FF00
highlight rubyInterpolation guifg=White
highlight rubyPseudoVariable guifg=#339999
highlight Constant guifg=#FFEE98
highlight Function guifg=#FFCC00 gui=NONE
highlight Include guifg=#FFCC00 gui=NONE
highlight Statement guifg=#FF6600 gui=NONE
highlight String guifg=#66FF00
highlight Search guibg=White
But the really cool thing about vim is that you can extend it using Ruby! More on this in a future post.



You can also do a bunch of fun stuff with both remote mode and the WIN32API calls for vim.
Posted by: Eric Hodel | September 04, 2006 at 09:34 PM
I'm a heavy user altough not an expert with Vi and derivatives. I do like the fact that there is a version of Vi in almost any platform. Most of the time I use Vi in Solaris but also have it on my Windows PC and in my FC4 partition.
I like simplicity and with Vi that's the name of the game.
Posted by: ChilliCoder | September 05, 2006 at 08:35 AM
Seems like I only leave commercial messages on your blog, John.
We added vi keybindings to Komodo this go-round, alphas still available for free at http://www.activestate.com/komodo
I personally find it still strange using vi keybindings in a GUI editor, but you can't beat the dot command.
On topic, back in college we used to play vi golf games -- carry out a task in the fewest number of keystrokes. Knowing how to use m, single-quote, and Unix commands can get you quite far relatively quickly.
Posted by: Eric Promislow | September 05, 2006 at 10:11 AM
I think we have a convert... haha, happy viming.
Posted by: scepticus | September 05, 2006 at 05:41 PM
vi golf? Wow. I bow before you, Eric!
Posted by: John Lam | September 07, 2006 at 07:29 AM
Did you consider using TextMate?
Posted by: John Topley | September 08, 2006 at 01:53 AM
I do use TextMate in a limited set of cases (like editing blog entries). However, I really need a cross platform editor (Windows / Mac) as well as having something with a very efficient input model. TextMate isn't cross-platform, so that's a bit of a deal-breaker for me since I spend most of my time writing code on Windows.
Posted by: John Lam | September 08, 2006 at 05:43 AM
I used vi almost exclusively for four years while in college. It was made clear early on by upper-classmen that vi was the cool editor, emacs was for the "weird" people, and there was a third editor (I forget the name) that was for "dummies".
I became an advanced vi 'er, but after 10+ years of Visual Studio and other BRIEF editors I don't know if I'd even know where to begin with vi anymore. It's good to see that that editing model is so widely available though.
Posted by: Edwin King | September 13, 2006 at 12:47 PM
Thanks for your initial VibrantInk port to Vim!
I made an actual Vim color scheme out of it, and added support for 256 color terminals.
More info: http://blog.jozilla.be/articles/2006/10/05/vibrantink-theme-for-vim
Download:
http://jozilla.be/data/scripts/vibrantink.vim
Cheers!
Posted by: Jo Vermeulen | October 05, 2006 at 04:51 AM