May 10, 2008

Why I Chose VI

Filed under: Uncategorized — bnsmith @ 8:21 am

Today, I finally made a decision. I will learn to use the vi text editor. Actually, that’s not quite correct; I plan to learn Vim, but you get the idea. Anyway, I have also decided to explain my reasons for this choice, in the hopes that it may be useful to other people who haven’t yet made a decision, just as I hadn’t, before today. I believe that I have made my decision on a rational basis, but that is for you to judge. Remember that I am new to both vi and Emacs. I haven’t invested several years of my life in mastering either one. On one hand, this means that I do not know enough about either to really judge based on their features. On the other hand, I believe this also leaves me largely unbiased. Until today, I would have been perfectly happy to select either one, had I encountered some incisive, knock-down argument in favor of one or the other. In the end, it was just a grab-bag of little things that finally pushed me over the edge. But first, perhaps it would be instructive to answer another, related question.

Why I Chose Nothing

A lot of you are probably wondering why it has taken me so long to pick one or the other. After all, vi and Emacs have been around for decades, and I’ve been a programming professionally for several years now. Well, it’s not as though I haven’t thought about it. Every time I encountered a co-worker who used one or the other, a little niggling doubt would pop into my head. What do they know that I don’t? What am I missing?

I gave the subject a great deal of thought, and decided that I should instead spend my time on languages rather than tools. Instead of learning a tool that makes it easy to add a lot of getters and setters to a Java class, for example, wouldn’t it be better to learn a language that doesn’t require getters and setters? I still feel this way, to some degree, and I certainly don’t regret my decision to learn about Python, Haskell and Scheme. Nonetheless, I now think that a little investment in vi will pay off in the long run.

Reason #1

I’m placing this reason first because it is the most immediate reason for me to learn vi. This is the reason why I am learning vi today rather than yesterday or tomorrow. Although I am still believe that learning more expressive languages is the better solution to repetitive editing tasks, I live in the real world. I am a working programmer, and it isn’t always reasonable to choose the exciting and obscure languages that I read about in my spare time. Beyond that, I have come to accept that there is more text out there than just raw code.

Today, I ran into a situation where I needed to edit a 20 MB data file. I tried to pop open gedit, but it wouldn’t open because of some null-bytes that appeared half-way through. Needless to say, this was not a problem in a real editor. I needed to cut this file down to isolate a bit of data that was causing problems. I wanted to search for a bit of text, and then delete everything above it to the start of the file. With vi, it is possible to hook an operation that you wish to perform to a selection command. To move to the start of a file, you can type ‘gg’. Therefore, to delete everything up to the start of a file, type ‘dgg’. Three characters is all that is required. If it had been a shorter file, I would have just held down the ‘Shift’ key and pressed ‘Page Up’ until I was at the top, then tapped ‘Delete’, and I wouldn’t be writing this post.

Reason #2

People often half-seriously suggest that Emacs isn’t an editor, it’s an operating system. The Emacs environment allows you to write programs, debug the programs you’ve written, check your mail, browse the web, play music, and a hundred other things, all without leaving the editor. The problem is, I already have an environment in which I can do those things: GNOME. I don’t feel the need to have another environment that runs entirely within a window on my GNOME desktop. Remember the Unix philosophy: write programs that do one thing and do it well.

Reason #3

This is probably going to be one of the more controversial reasons, given that I have so little to back it up, but I’ll mention it anyway, simply because I believe it and it has been a major factor in my decision. I believe that vi is currently more popular than Emacs. Linux Journal’s Readers’ Choice Awards for 2008 put vi in the top spot for text editors. Debian Administration also conducted a poll on the subject, though I admit that their numbers are probably unfairly skewed towards vi, given the site’s audience. There are a few bits and pieces of anecdotal evidence floating around, but the real clincher for me is the activity level. There just seems to be more going on with the vi community. There are multiple projects to bring vi-like features into Eclipse, as well as multiple GUI wrappers, including the intriguing Cream project.

Popularity isn’t everything, but it does matter, as I’ve described before in relation to programming languages.

Reason #4

I don’t want to get Emacs pinky. I do realize that it is possible to change the useless “Caps Lock” into a Ctrl key, and I have, in fact, done this previously. Still, based on what I have read, this improves the situation, but doesn’t eliminate it. I’d rather just avoid Emacs pinky entirely.


I’m not going to guarantee that I will spend the rest of my life becoming a master of Vim. I’m just going to make a point of learning some of the keys and using it regularly for a while. If it doesn’t stick, I’ll just move on to something else.


Create a free website or blog at

%d bloggers like this: