A while back, I tested and reviewed a slew of text editors for the Mac. Since then, I had primarily stuck with two editors - CotEditor for the stripped-down HTML of these blog posts, and TextWrangler for more serious coding. In my past, I'd made a point of learning Vi(m) for a handful of reasons:
- Need for a powerful text editor to quickly make edits from CLI
- Inclusion of Vi(m) is a requirement for POSIX-compliance
- Same as above, but more specifically, re: SSH
- Emacs sucks
In the previous article, I mentioned that 'for some tasks, I simply want to sit in my cuddly Cocoa environment,' the argument for my not spending more time in Vim on my Mac. This isn't the only reason - as extensible and customizable as an editor like Vim is, doing such customizations takes time. Setting up my keybindings in CotEditor was a mindless task, taking a handful of minutes while I casually sipped away a mug of tea.
Yet in the past week or so, I've needed to brush up on my knowledge of Vim, and pass along said knowledge to my girlfriend. In the process, I felt a longing, and an excitement whenever I went to switch modes. I realized that I should just spend some time and effort hacking away at .vimrc, .gvimrc, and an assortment of other files until I had a text editor which would suit my needs perfectly.
The first step was to get the latest snapshot of MacVim downloaded. I still like to feel like I'm in a Cocoa environment, I like to have simple access to mouse selection, mouse scrolling, OS X's pasteboard, &c. I spent quite a while making sure all of my favorite niceties were enabled in my .rc files - a solid font, line numbering, code folding, wrap indentation, wrap on word, &c. I'm still tinkering, and I'm also still working on my perfect colorscheme (a post for later!), but so far the adjustment has been simple and utterly pleasing.
So what are the advantages over my old system? First of all, I get the best of Vim and the best of a Cocoa environment (for the most part, see below). I have options - first thing in the morning, pre-coffee, I can click around… Once I wake up, I can use hjkl. Beautiful! But as far as actually working goes, there are quite a few benefits over how I was working before. My blog entries are saved as .entry files, yet should be parsed as HTML. In CotEditor, I just set HTML as the default for unrecognized files. In Vim, I just tell it that a .entry filetype is HTML - problem solved. Similarly, in CotEditor, all of my keybindings (such as Ctrl-P to insert a <p> tag) were active all of the time. In Vim, I just make a separate set of keybindings for any given filetype.
Because Vi(m) are so well-loved and well-used, the extensibility pays off in the number of plugins available. In addition to my custom keybindings (which is technically a vimscript plugin), I was easily able to find plugins to autocomplete my HTML tags as well as quotation marks, etc. There are a lot of great general-purpose utility plugins to make Vim do the things that the hardcore commercial text editors do (well, likely it's actually the other way around).
But I've also discovered a handful of additional plugins that really make my day. FavMenu gives me a Favorites menu in my menubar, to which I can easily add documents for quick retrieval later. The Vim Outliner makes outlining in Vim a breeze, and comes with a handful of scripts to convert said outlines to other useful formats. Finally, while I never really found much utility in a personal Wiki before, VimWiki puts a Wiki right inside Vim, and it has come in handy as a sort of personal notebook of things I should remember when I start writing for real.
Are there downsides? Yes. Even though MacVim is 'native' to an extent, it's also still a wrapper around a CLI program. The spellchecking uses its own dictionary rather than the inbuilt Cocoa dictionary. Additionally, I have no access to looking up words in Dictionary.app in case I need to check that I'm making sense. Scrolling necessitates moving around the cursor, which means that I lose my position from time to time. (S)FTP integration is a pain, so I'm still synching through ForkLift. Authentication (sudo) is a no-go from inside MacVim, likely because my shell of choice is fish.
For now, though, the benefits outweigh the costs. I can't see this changing, as I have pretty much adapted to the limitations, and the extensibility means that I'm likely to find additional solutions to my few woes. Truly, Vim feels like home.
shell=bash in my .vimrc file clears up a lot of issues. I can now use SudoEdit.vim to authenticate file read/writes, and the inbuilt SFTP support works as well. As much as I love fish, I'm willing to use bash inside of Vim to gain this functionality.
P.S. I also tried Mozilla's project, Bespin. It's pretty nice, with a handful of pitfalls that I'd expect from Mozilla. I'll try to write about that soon.