Why Does Vim Use H J K L? The Surprising History Behind vi’s Quirky Design
This article traces the origins of vi and vim—from early Unix line editors and the ADM‑3A terminal’s limited keys to the invention of command and insert modes—explaining why H J K L move the cursor, how the Esc key became essential, and how vi’s verb‑noun syntax lets users edit text efficiently.
1. The Early Days of vi
In the fall of 1975, Ken Thompson returned to Berkeley with a Unix system on a PDP‑11/70 and wrote a Pascal compiler. Bill Joy, then a student, discovered bugs in that compiler and began hacking it. At the time, no IDE existed; programmers used the line editor ed , also created by Thompson.
Ed was cumbersome, leading to a series of successors— em , en , eo , ep —and finally ex , a line editor that introduced a visual mode. Bill Joy refined ex into vi , the visual interface that became famous.
Unlike modern editors, these early tools lacked a cursor; they operated on whole lines, which made editing feel unintuitive to newcomers.
Example: correcting a typo in a two‑line file.
1
hello wold !
s/wold/world
1
hello world !This illustrates the cumbersome, line‑oriented workflow that vi later streamlined.
2. Keyboard Layout and Mode Switching
The ADM‑3A terminal, which Berkeley later acquired, had no dedicated arrow keys. Consequently, the letters H, J, K, and L were repurposed to move the cursor left, down, up, and right.
Additionally, the Esc key shared the same position as today’s Tab key, allowing users to switch between command and insert modes without moving their left hand.
These quirks persisted even after keyboards evolved, because users had grown accustomed to them.
3. vi’s Command Language
vi separates editing into verbs (actions) and nouns (text objects), optionally modified by prepositions that define scope.
d : delete
r : replace
y : yank (copy)
v : visual select
Nouns describe what is being edited:
w : word
s : sentence
p : paragraph
Modifiers (sometimes called prepositions) specify the range:
i : inside (e.g., diw deletes the word under the cursor)
a : around (e.g., daW deletes a word plus surrounding whitespace)
t : till (up to but not including a character)
f : find (up to and including a character)
Combining them yields expressive commands such as: diw – delete inside word cis – change inside sentence dte – delete till ‘e’ vis – visual select inside sentence
Because vi was written for 300‑baud modems, its design emphasizes minimal keystrokes and mode‑based operation, a philosophy that still influences modern Vim users.
Understanding this history explains why vi’s seemingly odd key bindings and modal workflow persist and why mastering them unlocks a powerful, efficient editing environment.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
