Demystifying text editor keystrokes

Impact of Design Decisions on Text Editors like Vi and Emacs with a deeper study of the origin of Navigation and Cut-Copy-Paste commands as we know it today.

Anuj Kumar
UX Collective
Published in
6 min readJun 6, 2020

--

II remember the early 2000s, my engineering days when I was first introduced to the world of text editors, like Vi. My friends use to tease me with the editor that doesn’t even move the cursor up and down using arrow keys. Today, almost two decades later, while I was switching between Vim and Emacs, I just thought of looking into the history of the editors to understand the design decisions for various commands and shortcuts esp. the ones that are used to navigate, cut, copy and paste. What unfolded was a series of historical hardware design and composition decisions that impacted the commands consisting of key combinations as we know it today.

Curious Case of Navigation Keys for Vi

Have you ever wondered why you can’t use arrow keys to navigate in Vi? The answer lies in the lineage of text editors and the hardware available at the time of its creation. Vi was derived from the various command-line editor of its time [2], like ed, em, en, ex, etc. Vi was the visual mode for ex editor that was inspired by Bravo.

Bill Joy, the original creator of Vi, used an ADM-3A terminal keyboard as shown below [2]. Due to the placement and ease of access, the Esc key became the most convenient way to switch modes. Also, there were no dedicated arrow keys on ADM-3A, instead, h,j,k,l keys were marked with arrow symbols, which is why Vi uses them for cursor movement.

ADM-3A terminal keyboard layout

When I started using Vi editor, there were dedicated arrow keys on the keyboard. So, the best way to remember them was to look at the lower case symbols j, pointing downwards and k, pointing upwards, and then left and right to it was H and L that intuitively worked for left and right.

Today, you are bound to use these keys for navigation in Vi, not because of Joy but Lear Siegler, an American corporation that used to manufacture car seats, brakes, and weapons control systems for military fighter planes. It ventured into Computer terminals in the 1970s and later released ADM-3A in 1976 [4] that gifted us h,j,k,l key bindings.

If you go further back in the history to 1870s, you will realize that even Lear Siegler and most of the other manufacturers got this QWERTY keyboard layout design from Christopher Latham Sholes who came up with this layout (with trial and error) to remove the basic flaw of typewriters that were susceptible to jams based on the earlier arrangement of keys on metal arms. So, collectively Sholes, Lear Siegler, and Joy gave you the navigation keys h,j,k,l for Vi.

Echoes the thoughts of Rich Hickey on the importance of Design and Composition and how it impacts the practices and tools for generations to come.

Evolution of Cut-Copy-Paste Commands

Most widely used text editing commands Cut, Copy, and Paste find its origin in the traditional practice of manuscript editing, where the first cut and paste was practiced by cutting paragraphs from a page and then pasting them onto another page. Later, with the advent of Photocopiers by Xerox, copy joined the party of cut and paste thus forming the strongest bond of cut — copy — paste [5]. Lawrence Gordon Tesler actually proposed the names cut, copy, and paste for the first time for text editors and also implemented it for a number of text editors, not to be surprised, at Xerox Palo Alto Research Center (PARC) almost two decades after the invention of Photocopiers.

In 1980, Tesler left Xerox PARC to join Apple Inc. as Apple was much more excited about the technology that Steve Jobs saw at Xerox during his visits. The effect of the research at Xerox PARC on Apple Inc. is still debated but Tesler being a part of Apple Lisa team, made cut — copy — paste widely popular first with Apple Lisa (1983) and then later with Macintosh (1984).

Apple also adopted the key combinations of letters Z (Undo), X (Cut), C (Copy), and V (Paste) with its Command key as they were all packed together at the left end of the bottom row of the standard QWERTY keyboard as shown below.

Apple Lisa Keyboard

If you look closely, the key ‘X’ resembles a pair of Scissors, ‘C’ holds good for Copy and the keys ‘Z’ and ‘V’ were a good choice due to their proximity to ‘X’ and ‘C’. This also made the cut — copy — paste functionality accessible without any awkward finger stretches even while holding the mouse on the right as per the norm.

Text Editing with Command Line Interface

Command-Line Interface (CLI) preceded the X Window Systems (X11). The use of x,c,v keys to cut — copy — paste was popularized with the X11 based interfaces in the 80s but the 70s were different. In Command-Line environments, in the late 60s and early 70s, with functionality in mind, the command Ctrl+C was used as an abort command with ‘C’ being considered as in Cancel. It was a part of various Digital Equipment Corporation (DEC) operating systems, including TOPS-10 (1967) and TOPS-20 (1976). It was later adopted by Unix as well due to its popularity in the 1970s.

Ability to do more on a command-line interface with minimal keystrokes gave birth to key bindings like ‘d’ for delete (cut), ‘y’ for yank (copy), and ‘p’ for put (paste) for mode based or modal editors like Vi. Modeless or Non-modal editors like Emacs, used the Command (Ctrl) and Meta (Alt) keys instead with bindings like Ctrl+w for wipe out (cut), Meta+w for copy, Ctrl+y for yanking (paste). These characters were picked purely as a design choice made by their developers based on some mnemonics like yank for ‘y’ that means to pull with a jerk and also because the keys like ‘y’ was free and did not interfere with other commands [6].

In most graphical desktop environments, you can transfer data (usually text) between different applications using a system facility called the clipboard. On X, two other similar facilities are available: the primary selection and the secondary selection. When Emacs is run on a graphical display, its kill and yank commands integrate with these facilities, so that you can easily transfer text between Emacs and other graphical applications. [7]

The table below summarizes some of the common keyboard shortcuts that are used to cut — copy — paste across different systems and editors [5].

Further, to increase the productivity over slow modems of the 70s, editors like Vi retained each permutation of typed keys to create a path in the decision tree which unambiguously identified any command that can then be executed in one shot. The method of typing ahead of display gave an immediate boost to the user’s productivity who used to type one key at a time and wait for the screen to refresh.

Development of Emacs started in the 1970s [1] and the first version of both Vi and Emacs was released in 1976 [1,2]. It also gave birth to the Editor War [3] that still goes on. That is the beauty of both of these editors. One modal, other non-modal, having completely different key bindings and boasting their place among the longest-lived application programs of all time [3].

Emacs came to me much later circa 2015 when I picked up Clojure as my programming language of choice. As of today, you can use Vim key bindings in Emacs via Evil mode and Emacs key bindings can be enabled in Vim via Vimacs package [3]

Importance of Key Bindings (Pun Intended!)

Key bindings matter. Placement matters. Believe me. I have experienced Emacs Pinky myself and can never forget the RSI pain. Here is the damage it did to the Ctrl key of my previous laptop. Of course, the pain was offset with the joy of code it punched out!

References

  1. https://en.wikipedia.org/wiki/Emacs
  2. https://en.wikipedia.org/wiki/Vi
  3. https://en.wikipedia.org/wiki/Editor_war
  4. https://en.wikipedia.org/wiki/Lear_Siegler
  5. https://en.wikipedia.org/wiki/Cut,_copy,_and_paste
  6. https://docs.freebsd.org/44doc/usd/12.vi/paper-4.html#section23
  7. https://www.gnu.org/software/emacs/manual/html_node/emacs/Cut-and-Paste.html#Cut-and-Paste

--

--