I. What's The Big Deal?

If you know what Vim is, you know it's just a text editor. You also probably know that a lot of people feel rather strongly about it.

What is it about this simple program that makes people so loyal? Its features are matched or exceeded by many modern editors and IDEs.

For me, the short answer is that Vim is the simplest, purest tool I've found for translating my thoughts into reality. As a musician feels about a favorite instrument, so do I love Vim.

Using it just feels good. Vim gets out of your way. Virtually anytime you think to yourself "gosh, it would be nice if--" it turns out Vim can do that without having to install any additional plugins. Want to make it permanent? Put it in your .vimrc, then never have to think about it again.

II. The Dance

So why haven't they just fixed it to be more intuitive already? The same thing that makes Vim so daunting for beginners makes it an excellent tool for experts. It has many features, but most of them aren't out in the open where you can see them.

There's no menus to click. Very little about using Vim is immediately intuitive to a random person who just happened to stumble across the command.

The noble explorer, however, will be rewarded quickly. A quick visual scan of the screen reveals instructions on accessing the help system, and even, a few sections in, a description of how to use the vimtutor program, which will bring most readers up to speed in a few minutes.

However, why would our noble protagonist invest the time? What's so great about using h, j, k, and l to navigate instead of the trusty arrow keys?

Vim's philosophy is centered around ergonomics, and favors ergonomic solutions even when the result is not immediately intuitive to inexperienced users. If that doesn't sound like a great way to attract customers, you'd be right. There's a reason more people know how to use Microsoft Word than Vim.

Those who forge ahead become witness to a symphony of ergonomic synergy. Vim is designed to allow the user to keep both hands on the keyboard and one's fingers on the home row as much as possible. It is an example of a modal editor, which just means it has more than one mode. In insert mode, Vim behaves much like Notepad. In select mode, keyboard shortcuts make the cursor fly to the precise place the user desires.

Blocks of text disappear and are rearranged instantaneously. Text is replaced on-the-fly. Custom keyboard shortcuts replace oft-typed commands. One feels a spectacular sense of unity with the machine, to the point one stops noticing it's even there. You fall into the rhythm, your steps gliding into a familiar, elegant dance.

It feels like knowing kung fu. At some point, the commands start to make sense together, to reinforce each other, and before one knows it, the muscle memory takes over and there is no going back. Every time I use another text editor, I feel a pang. I will sometimes silently hiss at web forms because the browser's text editor doesn't have the features Vim does. Chrome's little text box is bowling shoes when I have perfectly good rocket-powered rollerblades at home.

III. Synergy

Ugh, synergy. What a terrible word.

This is a rare case when synergy is actually a real thing that bears talking about, though. Using Vim in a bash shell in a tmux session on a remote server isn't just the hipster way of doing systems administration, it works. Staggeringly well.

Because I'm familiar with shell scripting techniques and tools, I wind up needing to use Vim less than I would otherwise. There are lots of times that sed and awk are more than enough firepower for a given situation.

Then when I wind up in Vim, I have at my disposal the entirety of my shell scripting toolkit. Just by typing :%! I can execute any arbitrary pipeline against the entire buffer of text I'm editing. I can execute commands against arbitrary ranges like :4,12!.

Vim also takes full advantage of the incredible power of regular expressions. Regular expressions, for those not in the know, are basically a search-and-replace feature so powerful that spending an hour learning them will make you feel like a superhero. Regular expressions also exponentially increase the power of tools like grep, sed, awk, and even less (and by extension, man.)

This tool that feels like conversing with an old friend can run in a terminal on a Linux server. Since I use tmux, that means that I can return to editing the same document from home or at work with a simple keyboard combination. If my computer crashes, the file is still there, just fine. If the server crashed, my text buffer would still be sitting there, just fine, my unsaved changes still available in a hidden file.

IV. Yeah But My Editor Has That Too

Vim's control scheme is so great that it's been copied over and over. (Vim is technically copying its predecessor, Vi.) There's Vim modes or plugins for most modern text editors and IDEs. "This way," one might think, "I can have the features of <other editor> and Vim's excellent control scheme, too." If you're comfortable with a tool, there's a lot to be said for the joy that can bring to your life. That is, after all, the subject of this essay.

Vim is built around a central philosophy of productivity through keyboard shortcuts and Unix tooling: repetitive motions are discouraged, replaced by a language of commands that can be fit together into sentences of precision and beauty. I do mean language; Vim allows you to express yourself clearly, quickly, and precisely. Anyone who has ever had to deal with a so-called "WYSIWYG" editor has experienced the pain of trying desperately to achieve a particular alignment, to have everything but the desired effect.

If every computer I ever owned and every account I ever used went up in flames, I could reproduce most of the important parts of my .vimrc file from memory, and the rest I'd rediscover almost instantly when I reached for them and found them missing. Like a musical instrument, the muscle memory carries over from one instance to the next. If you know how to play the piano, that doesn't go away when you sit down to a new piano. You just have to adjust the mirrors, buckle your seatbelt, and play.

There's probably other editors for which all of the above is true, at least under certain conditions. It's a tough competition, though.

V. What's a Vimrc?

Vim settings are stored in a hidden file called .vimrc. These settings tweak Vim's behavior, so that one doesn't have to enter these settings manually every time one starts the program. (The "rc" on the end stands for "run control." That means it's read and executed when the program starts.)

Here's a few of the features I'm fondest of:

Command Description
set ai Automatic indentation
set expandtab Use spaces instead of tabs
set hlsearch Highlights search results
noremap Remaps commands to hotkeys
set nu Displays line numbers

They might not look like much, but these short lines of text and others like it configure Vim to display specialized behavior as needed for different programmers and environments. For instance, as a Ruby programmer, I use spaces for indentation rather than tabs. set expandtab configures the tab key to emit multiple spaces rather than a single tab character. The number of spaces can be configured with set tabstop=<number>.

I like to have line numbers handy since I use ranges quite a bit. If the default color of the line numbers doesn't suit you, those can be configured too. Navigating the online help to discover all this can be a bit of an adventure-- but only as long as it's fun. One can always Google the question, and StackOverflow will be there, waiting with the answer.

VI. So Long, And Thanks For All The Text

The philosophy behind Vim enables a breathtaking degree of fine control. The learning curve is high, but the payoff is much more than worth it.

I fully expect to be using Vim for the rest of my life. So here's to you, Bram Moolenaar. You have brought me joy and prosperity. I can only hope to one day give back a fraction of the debt I owe to the open source community.