This is an story I found in ‘Learning vi and Vim Editors’ — which I started reading to ‘vim-maxx’:
Mary Ann Horton, who has been involved with Berkeley Unix since almost the begin‐
ning, tells the following story:
While the vi experience was much like Notepad, it was also a very powerful editor.
Students and faculty made heavy use of the power tools available, like the “global”
command that would make the same change on all lines matching some pattern, or
the ability to give commands like “delete 13 paragraphs” or “copy the text through the matching parenthesis.” But vi had a steep learning curve, and first-time users wanted
to use the arrow keys on their terminals to move around in the file, Notepad style.
Arrow keys didn’t work in vi, and for a very good reason. Users had a variety of
different brands of terminals, and all those terminals’ arrow keys sent different codes
when they were pressed.
Bill [Joy] didn’t have to worry about arrow keys. He had found a way to work from
home, getting a Lear-Siegler ADM-3A terminal in his apartment. The ADM-3A was
widely advertised as “the dumb terminal” because it didn’t have a lot of fancy features,
like arrow keys, allowing it to be sold for the then-low price of $995. Instead, LSI
painted arrows on the H, J, K, and L keys.4 Bill had set up vi commands to match: h
moved the cursor left, j down, k up, and l to the right. Every vi user had to learn h, j,
k, and l to move around the file.
What if you wanted to type a word with an “h” in it? vi, like ed, was a “moded” editor.
This meant you were either in “command mode,” where it treated keys you pressed as
commands, or “input mode,” where keystrokes were content to be added to the file.
A command like i for “insert” put you in input mode, and the Escape ( ESC ) key got
you back to command mode.
How to get arrow keys to work in vi? These special keys sent two or three character
sequences, usually beginning with Escape. We called them “escape sequences.” Escape,
however, was already an important vi command. It took you out of input mode, and
if you were already out of input mode, it beeped. One of the first things you learned
in vi was that, if you’d forgotten which mode you were in, you pressed the ESC key
until it beeped, and then you knew you were in command mode.
vi used a terminal capability database file called “termcap,” which told it which codes,
for your specific model terminal, to send to move the cursor, clear the screen, and the
like. It was easy enough to add the arrow key sequences to termcap.
If the computer received an Escape, was the user hitting the ESC key or an arrow
key? Should the editor exit input mode, or should it wait for more text to interpret
an arrow key? Once the editor tried to read more text, the program would hang until
something came in.
Fortunately, a new Unix feature allowed the editor to wait briefly to see if another
character came in. If that character might be part of a valid escape sequence, vi could
keep reading to see what other key the user had pressed. If no more characters came
in for that brief interval, the user must have pressed the ESC key. Problem solved!
Around the spring of 1979, I added code and termcap entries for vi to understand
arrow keys, Home, Page-Up, and other keys that some of the terminals had. I configured termcap as if the ADM-3a had arrow keys that sent h, j, k, and l; and
then I deleted the hardcoded h, j, k, and l commands. I thought I had it all fixed up.
Within a day, I had a line of angry CS grad students outside my office door. Peter
was at the head of the line. He wanted to know why I broke hjkl on his terminal. I
explained to him that his arrow keys worked now, and he didn’t have to use hjkl; he
could use the arrow keys instead.
Peter rolled his eyes. “You don’t understand,” he said. “We like using hjkl! We’re
touch typists. Our fingers are right over the hjkl keys. We don’t want to have to
move them way to the edge of the keyboard to use arrow keys. Give us back our hjkl
commands!” The line of students agreed.
They were right. I put back hjkl and left the arrow key functionality in too. And
I realized how important the key placements of vi commands were. Almost any
command you used often was a lowercase letter. I got really fast with vi, and to this
day I prefer vi to edit text files. I’ve trained several classes of IT professionals how to
get the most out of vi and Unix power tools.
Because J looks like a down arrow, obviously! /s
I’m wondering if there was some other popular interface for some other device (elevators perhaps?) That had Down on left and Up on right.
Since for an elevator, up is forward and down is backward…
And I wonder if they copied from that order, not thinking about (or remotely expecting) the UX of how down on left would fuck people up for countless years to come.