Heretical Confessions of an Emacs Addict – Joy of the Vim Text Editor

Context

As an experiment, I have recently started using Vim as my primary text editor. While I have been an Emacs aficionado for a very, very long time – clocking in at almost 16 years – Vim is something that I have always been curious about, and tinkered with from time to time, while ending up going back to Emacs. This time however, I intend to stick around for a while, and try to get a feel of the Zen of Vim.

The Emacs and Vim Icons

The experience with Vim has been rather pleasant so far. While  configuration is definitely a must (just like Emacs), out of the box experience is not bare bones either. In fact, the default settings are rather good, and one can get a lot of mileage from the vanilla setup.

The USP of Vim is that it is first and foremost a text editor, and does not attempt to be THE kitchen sink. In other words, its core focus is to provide the best and most functions to manipulate text; it is not to provide a universal platform where one of the applications happens to be an editor.

The Editing Model

The very first experience the user gets on launching Vim is that it is a modal editor, with distinct modes for entering text, and editing it.

This is in stark contrast to most other editors, which provide the editing functions via other mechanisms, such as menus or key chords (à la Emacs). While this might seem odd at first glance, it is definitely a key component of Vim’s power, and arguably its success as a text editor.

In addition, the second key distinguishing factor of Vim is that its editing is based on a “noun-adjective-count-movement-verb” model of editing. Nearly every editing command is a sequence of one or more of these primitives, where the intent of the edit operation is usually fully mapped to the encoding offered by various combinations of these primitives.

As an example, to move 5 lines down, and then 3 words forward, to delete the next two words, the following “primitive encoding” can be used:

      5j 3w 2de 

While this is a rather trivial example, it illustrates a key principle of using Vim – the editing model is based on MOVEMENT and MANIPULATION, explicitly and succinctly made via the modal key-chords which apply the same basic foundational model at all scales.

To a large extent, this underlying pair is what the user usually is thinking about, when an editing operation is being thought of. The primitives are just the vocabulary to tell Vim to execute the intent.

The movement itself can be further separated into raw movements (i.e., lines and characters), or be semantic oriented (words, sentences, paragraphs, functions, etc.) This can sometimes be further refined using “adjectives” such as “begin”, “end”, “between”, or “surrounded”. In addition, the count represents multiples of the movement unit being specified, and allows velocity of the movement to be increased significantly.

The verb is of course where the “real action” happens. In a general sense, every verb is really a “change” verb, with specializations of “delete”, “replace”, “convert”, etc.

Conveniences

In essence, the core feature set of Vim (and certainly its spiritual ancestor – Vi) can be adequately expressed by the core model described above.

However, a basic feature does not make a competent editor. This requires other user comforts such as multi-file edits, windowing mechanisms (including split windows), language syntax, external tool integration (spell checks, compilers, shell interaction), extensive customization to fit the user’s need, an usable in-built help system, and many more such features that make regular usage comfortable and transparent. And Vim does have all of these in abundance, with parity with Emacs in most of these areas in terms of feature completeness, and power.

Granted, Vim does not yet have an inbuilt News Reader, or an email client, but the core editing functions are very much there, or easily added via plug-ins.

Conclusions

The feeling I get from using Vim is really about efficiency and focus, while Emacs seems to exude more a sense of power. Both can be frustrating at times, often from over-abundance of features than anything else, and hidden functionality that takes years to internalize before returns are gained.

Vim and Emacs are both excellent editors, and share a lot in common. The complexity, feature-richness, and the high learning curve are the ones that stand out the most. Also, the vibrant community around both editors is a shared characteristic.

Editor wars aside, both are very competent and complex pieces of software, and will serve the user well, provided an investment is made in learning the unique interfaces that both exhibit.

As for me, I do not anticipate leaving the Emacs bandwagon any time soon — especially with significant investments now in the Orgmode work-flow that I have built up over the past few years. However, I do see Vim as another pro-tool in my toolbox, which is definitely going to get a lot more love and use in the days ahead.

Advertisement

Replacing Mail.app with Gmail on OSX

Off late the Mail.app email client on OSX has been acting up on me. It often stalls or displays the spinning beach ball of death till a forced quit is required. Also, it seems to have display rendering issues when a mail classified incorrectly as junk is moved back to the inbox.

I tend to use the Mail.app as a local email client for three main purposes:

  1. Offline mode for reading my emails when there is no Internet connection available
  2. Easy desktop search for the mails via Spotlight, and
  3. Easy archival of important mail in my project workspaces (either in Devonthink or plain text export)

The other features (TODO and Notes) are nice, but not really useful for me as I use other tools for these items. The mail itself is served out via gmail accounts and IMAP synchronization.

However, Mail.app is one of the few (only?) Apple provided applications that I have a love-hate relationship with. I love the fact that it integrates seamlessly with iCal and Address Book, and the other features such as support for multiple signatures, digital signing and encryption via the GPG plugin and the smart quote while responding are quite good. the threading is also functional.

But the incessant crashes and freeze ups are getting to be more than annoying. I have tried the various cures such as re-synching the entire mailbox, rebuilding the mailbox, trashing preferences, changing the cache setting and a ton of other voodoo. These seem to be temporary solutions however, and the problems come back pretty fast. Apparently I am not alone in my suffering though – Apple’s discussion and support forums are full of unhappy Mail.app users.

So I am now on the hunt for an alternative offline/local client solution. I have already tried Mozilla Thunderbird, and it looks too ugly for my tastes (though an excellent client on the Windows platform). In addition, two more deal-breakers exist right now:

  1. Getting Spotlight to work with Thunderbird requires a third party indexer which seems to be a hack. It looks like an experimental mdimporter plugin does come with version 2.0 but is flacky
  2. Missing integration with the system provided AddressBook.app application (I need to sync the addresses with my Blackberry, and AddressBook.app is a core part of the synchronization workflow)

Another promising solution seems to be using Gmail directly as the primary email client. This requires a few additional steps to enable a seamless offline operation:

  1. Installation of the Google Gears extension for the browser (no support yet for the latest Safari 4.x version) – this enables a copy of the emails to be stored on the local disk and allows access and usage of the gmail interface when offline – note that the first-time sync takes a long time as last 6 months worth of emails are downloaded to your computer – it is pretty peppy from then on
  2. Installation of the Gmail Notifier application which provides notifications on receipt of new emailgooglenotifiersignin.png
  3. Setting up Gmail as the default mail handler from URLs by using an option on the Gmail notifiergooglenotifierpreferences1.png
  4. Using a Site Specific Browser such as Fluid.app or Mozilla Prism and creation of a Gmail SSB application (remember to set a nice icon)fluid1.png
  5. Setting up the Gmail SSB as the default mail application by setting the “Default Mail Reader” option from Mail.app’s general preferencesmail-appgeneralpreferences1.png
  6. Synchronizing the addresses between Addressbook.app and Gmail using iSyncaddressbookpreferences.png
  7. Using Google Desktop for searching the mails on Gmail

Whew! Quite a bit of setup here to do – and it is still not perfect. Lets look at the pros and cons:

Pros:

  1. Can use the excellent Gmail UI everywhere, online or offline – on all platforms. Hurray for Web apps!
  2. Great keyboard shortcuts – much better than Mail.app
  3. Using the SSB allows a smooth integration of the mail experience with rest of the desktop
  4. No more waiting for the local client to download the mails before accessing – it is near instantaneous after the first offline synchronization
  5. No more crashes!

Cons:

  1. It is a hack right now – definitely not a “download and start using” solution
  2. Google Desktop is duplicating search functionality that already exists via Spotlight
  3. Synchronization of the addresses between Gmail and AddressBook is not reliable
  4. No support for multiple signatures (can get around with a auto-typing solution such as Typinator or TextExpander)
  5. Cannot export the emails (not the contacts) from Gmail to the local computer

I intend to use this setup for the next couple of weeks to get a better feel of the system. Will follow up with a post on the findings. Do let me know what you think.

Do you Twitter?

Twitter is one of those Web 2.0 applications that at first 
glance seems to beg the question: why? But first, a description of the service 
from its home page:
Twitter is a service for friends, family, and co–workers to communicate and 
stay connected through the exchange of quick, frequent answers to one simple 
question: What are you doing?
In short, it allows you to post a short description of what you are doing right 
now (or in fact, any short phrase at all – the trend seems to be for posting 
witty or funny comments).
The next obvious thing is to track what others are doing – which can be a 
limited set of your friends, or for anyone who has chosen to make their status 
public.
Another interesting use is to use it as a virtual SMS mechanism on the 
web – you can choose to only track your friends, and use the service to keep in 
virtual touch with each other.
Twitter offers tracking and update via the web, IM as well as SMS via a 
cell-phone.
The service has already gained a large following, and many web celebrities such 
as Marlin Mann of 43Folders fame or Cali Lewis from 
GeekBrief TV are on board.
Yours truly is also testing the waters right now, and has the handle evolve75 
on the service.
There are also quite a few tools already available to make the usage easier. A 
Firefox extension called twitbin enables live tracking via 
a side-bar on your browser, and OS X dashboard widget called 
Twadget is available for updating Twitter from your Mac desktop (for 
Vista users, an alternate version for the sidebar is available 
here).
Whether Twitter is just another Web 2.0 meme – or here to stay – remains to be 
seen. The service is useful, but carries the risk of the novelty fading away 
to becoming a chore 😦
~ Anupam