Technical Beauty ■ Episode 28
2.7 million people have visited Stack Overflow to learn how to exit a text editor. One in every 20,000 visitors. During peak hours, 80 people per hour, trapped in a program they opened by accident.
The most feared tool in computing is also the most elegant. One does appreciate the irony.
The Constraint
1976. Bill Joy, graduate student at UC Berkeley, writing code over a 300 baud modem on an ADM-3A terminal. Three hundred baud is roughly 30 characters per second. The screen redraws slower than he can think. Every keystroke costs time. Every wasted character is a visible delay. At 300 baud, a full screen redraw takes nearly three seconds. Three seconds of staring at a cursor, waiting for the machine to finish drawing what you already know is there.
So he built an editor where nothing is wasted. No menus. No mouse. No chrome. No decorative pixels. Every single key does something useful. The entire interface fits in 24 lines and 80 columns, because that is what the ADM-3A had, and not one row was going to be sacrificed to a toolbar.
The Escape key sits where Tab sits on modern keyboards, because on the
ADM-3A it was one finger away from the home row. hjkl
navigates because the ADM-3A printed arrow symbols on those keys.
Colon enters command mode because on that keyboard, colon required no
Shift. The tilde (~) was printed on the Home key, which
is why Unix still uses ~ for the home directory fifty
years later.
vi was not designed for comfort. It was designed for a 300 baud modem and a terminal that could barely keep up. The constraint produced the grammar. And the grammar, as it turned out, was so good that it outlasted the constraint by half a century.
The Grammar
vi is not an editor. It is a language.
Every other editor maps actions to key combinations.
Ctrl+C, Ctrl+V, Ctrl+Shift+K.
Fixed bindings. Memorised, not understood. You learn them one at a
time, each independent of the others, each a dead-end of muscle
memory. Two hundred shortcuts, each an island.
vi gives you a grammar. Verbs, counts, and nouns. They compose.
d3w: delete three words. ciw: change inner
word. yy: yank this line. p: put it back.
d$: delete to end of line. ci": change
everything inside the quotes. gUw: uppercase a word.
3dd: delete three lines.
Learn 10 verbs and 10 nouns and you have 100 commands. Learn 20 of each and you have 400. The growth is multiplicative, not additive. Every new verb works with every existing noun. Every new noun works with every existing verb. The vocabulary compounds. The shortcuts in every other editor grow linearly: one binding, one action. vi grows quadratically: one new word, dozens of new sentences.
A three-year-old composes sentences from verbs and nouns without memorising every possible combination. That is how vi works. One rather suspects the linguists would approve.
The Modes
The terror that sends 80 people per hour to Stack Overflow is modal
editing. vi has two primary modes: normal mode, where every key is a
command, and insert mode, where keys produce text. Press i
to enter insert mode. Press Escape to leave it. That is
the entire cognitive load.
Every other application on your computer is permanently in insert mode. You type, letters appear. To do anything else, you hold modifier keys: Ctrl, Alt, Shift, Command. Your fingers contort into chords. Your pinkie learns to live on Ctrl. Repetitive strain is not a bug. It is the architecture.
vi inverts this. You spend most of your time navigating, searching, composing commands. You spend a minority of your time actually inserting text. Modal editing reflects this reality. It puts the common case, not the obvious case, in the default mode. The idea is not intuitive. It is, however, correct.
The Legacy
vi is specified in POSIX. It ships with every Unix system. Every BSD server. Every Linux. Every macOS. It has been there since 1976. Fifty years of production. No subscription. No update that rearranges the interface. No deprecation notice.
Bram Moolenaar took vi and built Vim in 1991. He maintained it for 32 years. He coined the term “charityware” and asked users to donate to orphans in Uganda instead of paying for the software. He died on 3 August 2023, aged 62. Christian Brabandt continues his work. The editor Moolenaar built runs on more machines than any other text editor in history.
Vim: 380,000 lines of C. VS Code: Electron, Chromium, Node.js, hundreds of megabytes. Both edit text. One was built by a man who asked you to help orphans. The other was built by a corporation that would rather like you to use their cloud services. One leaves a small footprint on your machine and a large one on the world. The other does the reverse.
The Point
The constraints of 1976 produced an editing grammar that no modern editor has matched. Not because modern editors lack features. They have features vi could not dream of: language servers, inline debugging, collaborative editing, AI completion. But they lack a language. They map fixed actions to fixed keys. They grow additively. vi grows multiplicatively. The difference is not power. It is composability.
There is a reason that every serious editor now offers a vi mode. VS Code
has one. IntelliJ has one. Sublime Text has one. Even Emacs has
evil-mode. The grammar is so good that editors built on
entirely different architectures bolt it on as an afterthought. Nobody
has ever bolted Ctrl+C/Ctrl+V onto vi. The traffic is strictly
one-directional.
vi is a 50-year-old proof that designing for constraints produces tools that outlast the constraints themselves. The 300 baud modem is gone. The ADM-3A terminal is a museum piece. The grammar they produced is immortal.
A text editor designed for a 300 baud modem in 1976 produced a composable grammar that no modern editor has matched. Every key does something. Verbs compose with nouns. Ten of each give you a hundred commands. The constraint is gone. The grammar remains. Fifty years of production. Zero licence fees. One man asked you to help orphans instead of paying.