vi was written by Bill Joy in 1976 for BSD Unix, for a world of slow serial terminals where every keystroke sent over the wire was expensive — hence a language of single-letter commands and no menus. Vim ("Vi IMproved") followed in 1991 and is still, thirty-plus years later, what half the internet's servers get edited with over SSH. The best way to learn it isn't to read about it — it's to type into it. Below is a small but real modal editor, implemented in JavaScript, with six guided lessons.
Click the black terminal above, then type. It captures your keyboard the way a real terminal window would — click elsewhere (or press Esc then Tab) to escape it.
| Key(s) | Mode | Effect |
|---|---|---|
h j k l | Normal | move left / down / up / right |
0 / $ | Normal | jump to start / end of line |
gg / G | Normal | jump to first / last line |
i / a | Normal | insert before / after cursor → INSERT mode |
I / A | Normal | insert at start / end of line |
o / O | Normal | open new line below / above → INSERT mode |
x | Normal | delete the character under the cursor |
dd | Normal | delete (cut) the current line |
yy | Normal | yank (copy) the current line |
p | Normal | paste after the current line |
V | Normal | enter VISUAL LINE mode (select whole lines with j/k) |
d / y | Visual line | delete / yank the selected lines |
Esc | Insert / Visual | back to NORMAL mode |
: | Normal | enter COMMAND-LINE mode (bottom of screen) |
:w :q :wq | Command-line | write / quit / write-and-quit (simulated) |
See also: 1959 LISP console (prefix / Polish notation) · 1970 FORTH terminal (postfix / RPN) · 1985 dial-up BBS · 1993 Mosaic homepage · 1991 Gopher menu · return to the surface (WWW homepage)