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.
