Thoughts on VIM

Joe Gregorio

I said I was leaving emacs, and I have. I am now in the process of learning vi, or more precisely VIM.

VIM is a quite mature and capable platform, not the same vi I used years ago on Sun stations. It is a rewrite of the vi editor, with Bram Moolenaar as the main author and maintainer. It has all the major features you'd expect from a modern text editor such as syntax highlighting and scriptability.

Learning it has been quite fun and the transition from emacs to VIM has been quite enlightening. Here are some of my observations as I move from one to the other.

This honestly is the hook that got me to try VIM in the first place, the comment that VIM could be scripted with Python. I've got my weak spots, and that hit it. I have never fully wrapped my head around emacs lisp, and never thought that it was an appropriate scripting language for an editor. VIM has it's own language plus allows you to script in other languages. Talk about pushing my buttons.
Emacs is driven by Control and Meta key combinations. They're nice and short but not very mnemonic. VIM on the other hand uses words, honest to goodness words to perform actions. Part of this difference is modalness, which I will talk about next. Want to create a new buffer? That's :new. How about editing a file? That's :edit. All of the commands have shorter versions that are accepted, for example :e for :edit. The neat thing is that you can type in a partial command then press the tab key to cycle through all the possible completions. That's the power of language.
VIM has a modal interface, that is, you can be in one of several different modes at any one time. For example when you first start editing a file you are 'Normal' mode, press i or a and you are in 'Insert' mode, a mode that allows new text to be inserted. It's interesting that 'modal' interfaces today are generally eschewed, being considered too difficult to learn and too mistake prone. I thought this too until my switch to VIM. Interesting also that I just saw a small bit of an interview with Dr. Douglas C. Engelbart, who for just one of his accomplishments invented the mouse. He talked about the current user interfaces to applications as being mouse driven and very easy to learn, but in the long run that same mode of interaction made the programs less productive than it could be. Using the mouse, Ctrl keys, and Meta keys allows you to avoid creating a program with a modal interface, but at what cost? Drop language as a primary interface mechanism and you can create a non-modal interface, but in the process are you losing too powerful a tool? It does make me wonder if modality and language are the key to the popularity of certain programs, for example for the third year in a row Vim was voted favorite editor. Similarly there is the fanatical following of xyWrite.
Speaking of modality, you might be interested in this tutorial about how to move the cursor one character forward in vi.

Posted by Mark on 2003-10-12

Cool, glad you're checking out vim.

If you search around a bit on google you'll find an implementation of the game of life in vims built in scripting language. Crazy vim hackers :-)


Delete all lines not matching pattern 'line'

Posted by Anu on 2003-10-13

You say:

Emacs is driven by Control and Meta key combinations. They're nice and short but not very mnemonic. VIM on the other hand uses words, honest to goodness words to perform actions.

Which isn't entirely fair -- any command that you can run via some Control/Meta/Alt combination in Emacs can also be run by doing 'M-x command'. That doesn't seem substantially different than ':command' to me.

As for how mnemonic the combinations are, changing them is always an option...

Posted by genehack on 2003-10-13

Mark is trolling of course; you can use the arrow keys to do that in vim, regardless of mode.

Posted by foo' on 2003-10-13

Perhaps my howto is of interest to you:

Vim as XML Editor

It's still a draft, I appreciate any feedback.

Posted by Tobi on 2003-10-18

  Thanks for the pointer. I will definitely check it out.

Posted by joe on 2003-10-20

You script emacs with pymacs, although it does require some emacs lisp knowledge.

Posted by Robert Sayre on 2003-10-29

comments powered by Disqus