Wandering Thoughts archives


Some reasons why I like vi

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.)

unix/LikingVi written at 01:30:02; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.