Back to Vim

Kimo Johnson

30 March 2007

About eight months ago, I switched back to vim as my main editor. I had been using TextWrangler for a few years, but before that I was a vim user, and somewhat of a power user as well. I think the main reason I had moved away from vim was the lack of tabs, or perhaps it was simply the un-maclike experience. TextWrangler offered a familiar interface and had a nice feature set (for the price). But, I was interested in an editor with more power and better syntax highlighting. I briefly tried TextMate, but wasn't impressed enough to switch. So I came back to vim, which now has tabs and can become somewhat maclike with plenty of customization.

Here is a short list of customizations I have made, either through my vimrc or by compiling my own version.

  • Bold and italic fonts. I use Microsoft’s Consolas font, which is a monospaced font with bold and italic versions. In order to enable italic font support in vim, I had to edit three source files and recompile, but it was worth it.
  • Guitab. The guitab patch shows tabs in a drawer similar to TextWrangler.
  • Tab completion. Vim 7 has omni-completion, but I find the default keystroke to be awkward. Following a tip posted to the vim site, I remapped omni-completion to the tab key.
  • MRU. The most-recently-used plugin is really handy. Typing “:MRU” shows your recently used files.
  • Align. The align plugin lets you easily align your code about different characters. It’s great for cleaning up a LaTeX tabular, or aligning a bunch of assignment statements about the “=”.
  • Syntax highlighting. I tried lots of color schemes from the vim site, but none of them were just right. Mine is loosely based on XCode’s colors and used both bold and italics. It also looks good in the Terminal, which has a more limited set of colors and options.

There are many more small tweaks documented in my vimrc and syntax highlighting files, but I’ve been relatively happy with them for a few months. I say relatively, because there are still a few issues I would love to figure out, including:

  • Open files in new tabs on drag-and-drop. Currently, the file opens in the window you’re viewing and you have to type “:tab ball” to get it into a new tab. I’ve tried suggestions for opening all files in new tabs, but I prefer help files to open in split windows as they do now.
  • Add new tabs to the end of the tab list. I think they open above the current tab right now.
  • Faster scrolling. Scrolling seems slow compared to TextMate or perhaps even TextWrangler. Plus it moves the cursor, which is un-maclike.
  • Faster typing. It’s subtle, it feels like vim lags slightly behind me as I type. I don’t get the same feeling when typing in TextMate.
  • More intelligent paragraph reflow for LaTeX (and possibly other languages). I’d love to get vim to recognize that paragraphs in LaTeX end when equation environments begin. With “gqap”, vim reflows equations that are attached to paragraphs.
  • Make “gf” (goto file) switch tabs if the file is already open in a different tab.

But even with those issues, I still prefer it to any other editor I’ve tried. I’ve been tempted by TextMate on several occasions, specifically by its snippets and macros, but keyboard navigation in vim is really fast once your fingers get used to it. And, vim doesn’t look too bad once you customize it. For example, here’s a screenshot of my customized vim in action. Any comments (or fixes for my list of complaints above) are always appreciated.

Update 1/26/2009

I have been using MacVim for over a year and it is certainly the best OS X port of Vim I have used. The tabs are much nicer than the Guitab patch mentioned above and I can open new files in tabs on drag-and-drop. I updated the screenshot above to show my current setup.

MacVim screenshot