History of vi Keys
How Did Vi's Command Mode and Insert Mode Idea Came About?
Back in 1970s, terminal screen are 80 columns by 24 lines. There's no real-time editing. You edit by typing a command, then call another command to have the screen update to show the result of your command. Vi's “modal editing” is evolved from this. This is also why emacs's manual calls itself “Real Time Display Editor”. Emacs is the first or one of the first “Real Time Display” editor.
The unix text editor vi was originally written by Bill Joy in 1976. Since, there are many clones. vim is currently the most popular, began in 1991.
〔see Keyboard History ⌨〕
Why vi uses H J K L for cursor movement?
Unix vi's use of H J K L for cursor movement, came from the keyboard it was developed on, the ADM-3A terminal. The keyboard has arrows printed on the H J K L keys.
Note the position of the Escape key and the arrows on H J K L, and the position of Ctrl, and position of the colon : key.
vi's choice of Escape key for mode switching, also came from ADM-3A keyboard. It is the most obvious choice on that keyboard.
Why Does ADM 3A Terminal Keyboard Use H J K L for Arrow?
〔see ADM-3A Terminal Manual〕
The reason seems to be part cleverness and part from the design of the ASCII Encoding , which involved a clever assignment of binary code to the letters, and the control characters.
Basically, the binary code for a letter, and its version with Control key held down, differ by 1 bit, and the control held down version of the letters H J K L, happens to be the ASCII non-printable backspace, linefeed, vertical tab, formfeed, and these control characters, happens to be the most apt choice as arrow directions. (there is no dedicated arrow character in ASCII code.)
ASCII Char | backspace | linefeed | vertical tab | formfeed |
---|---|---|---|---|
decimal | 8 | 10 | 11 | 12 |
binary | 00001000 | 00001010 | 00001011 | 00001100 |
Input Method | Ctrl+h | Ctrl+j | Ctrl+k | Ctrl+l |
ASCII Char | h | j | k | l |
---|---|---|---|---|
decimal | 104 | 106 | 107 | 108 |
binary | 01001000 | 01001010 | 01001011 | 01001100 |
ASCII Char | H | J | K | L |
---|---|---|---|---|
decimal | 72 | 74 | 75 | 76 |
binary | 10001000 | 10001010 | 10001011 | 10001100 |
For example, letter h has binary code
01001000
with Control key held down, it sends the non-printable character Backspace, which has binary code
00001000
and this Backspace character, is most suitable to be considered as left arrow.
The vi designer Bill Joy, simply used the same key in vi, without needing to hold Control key.
Interview with Bill Joy (creator of vi)
HJKL keys and vi
Keybinding and Input-System
- Why Alt Tab is Bad for Switching Windows
- How Many Shortcuts Are There
- Emacs vs vim, Keybinding Efficiency
- vim HJKL vs IJKL
- Gamers WASD Keys
- Design of vim Mode Activation Key
- History of Key Shortcuts: Emacs, vim, WASD
- History of vi Keys
- Muscle Memory vs Mnemonics
- Ctrl ❌
Ban Key Combos - Ban Shift Key
- Function Key vs Key Chord
- Fast-repeat vs Non-fast-repeat Keys
- Modifier Keys Usage Frequency
- Keyboard Shortcut vs Launch Buttons
- Best Way to Insert Parenthesis/Brackets
- Math Input Design
- Create Math APL Keyboard Layout
- Linux Mac Windows, Which is Best for Keybinding?
- Dual-Function Keys (Home Row Mods)
- Xah Shorthand System (Abbrev Input)