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 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.
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.
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.
15 thoughts on “Heretical Confessions of an Emacs Addict – Joy of the Vim Text Editor”
Because emacs features everything it does of course feature a vim emulation, too.
Check out `evil’: http://www.emacswiki.org/emacs/Evil
I’m loving emacs but I couldn’t do without modal editing (I’m coming from vim).
Look at Evil: it brings vim-like modal editing features and is really awesome !
Best of both worlds …
Wow, and here I’d still been using vimpulse. Evil is great.
(evil-define-motion evil-little-word (count)
(let ((case-fold-search nil))
(search-forward-regexp “[_A-Z]\\|\\W” nil t)
(define-key evil-operator-state-map (kbd “l w”) ‘evil-little-word)
Now “clw” and “dlw” delete parts of snake_case or camelCase words.
Emacs is a swiss army knife.
Vim is a chainsaw.
I think you got it backwards. Vim is much simpler, and doesn’t strive to be fully customizable, as this article points out.
Emacs is a swiss army knife.
Vi(m) is a surgical scalpel.
Emacs is a swiss army knife.
Vi(m) is a surgical scalpel ON my swiss army knife (with Vimpulse, soon to be Evil).
nice to see a rational, fair review of an editor many see as the “enemy” 🙂 Thanks for the nice read!
Your movement example is missing an ‘e’ 😉
Great read! (I’m a vi[m] user who uses emacs for LaTeX and orgmode)
Thanks for pointing this out. I have corrected the example accordingly.
I think so too. Because of org-mode and the plugin org2blog (https://github.com/punchagan/org2blog) I will never leave my emacs 😉
Do you using org2blog here?
There is an org-mode-alike for Vim called VimOrganiser. It may be handy if you want to carry on with Vim for a while.
Russell Freeman reblogged this from Russell's Rants and Raves and commented:
Sometimes you need to try the dark side. 🙂