Some reasons why I like vi

December 17, 2008

I will reluctantly admit it: I sort of like vi. It is a grudging like, for vi is not my favorite editor and it has its weaknesses, but still, there are things about vi that I keep finding cool and nice and attractive. One significant reason is vi's regularity and what I will call 'composability'.

(Let me note that by 'vi' I mean the entire vi family.)

To make up terminology, vi more or less has two sorts of commands: commands that change the text (call them 'action commands'), and commands that move the cursor (movement commands). Vi's regularity and composability is that pretty much every action command can be used with pretty much any movement command to specify what to operate on.

Once you learn this and it really sinks in (which took a while in my case), what you get is an immense amount of leverage for your vi knowledge. If you know a navigation trick, you can extend it to select text for action commands. When you master a new movement command, all of your action commands also get more powerful; when you master a new action command, all of your movement commands get more useful. When you learn something new, it doesn't just add to your abilities, it multiplies them in a virtuous feedback loop.

(I think that this is a great way of growing people's expertise and rewarding them for it. Unfortunately it is hard to copy in other contexts.)

This interacts nicely with another reason I like vi: its support for pipes, specifically piping text through commands. Pragmatically, this means that I can extend vi (in some ways) by writing shell scripts and hooking it to specialized superintelligent programs like par. Since piping is just another action command, it takes all of the usual movement commands for text selection.

As a side note, this composability also gives you little things to figure out and learn all the time. Even if you're not learning new movement and action commands, you can always see if you can come up with anything useful to do with a combination you haven't tried before.

(Since this experimentation gives you a stream of little rewards for playing around with vi, it is perhaps no wonder that people wind up loving it.)

Written on 17 December 2008.
« Why XHTML is doomed, at least in its strict validation form
Why LVM snapshots should really have hooks into filesystems »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed Dec 17 01:30:02 2008
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.