Why Emacs Keys are Painful

This article shows why Emacs's keyboard shortcut set is the worst with respect to ergonomics.

A important aspect in designing a keyboard shortcut set, for a application that has intensive, repetitive, prolonged human-machine interaction (such as coding and text editing), is to consider ergonomic principles. Specifically: the top most frequently used commands should have the most easily-to-press keystrokes. For example, they should be on the home row.

The Tragedy of Ctrl/Meta Swap

Emacs's keys are designed with a keyboard that practically has the Ctrl and Alt key positions swapped.

LMI Lambda keyboard [image source https://deskthority.net/keyboards-f2/cadr-lisp-machine-keyboard-the-space-cadet-keyboard-t19373.html ]

[see Lisp Machine Keyboards]

The keyboard used by emacs developers at MIT AI Lab in the late 1970s are those keyboards from Lisp Machines. (GNU Emacs by Richard Stallman, with builtin language Emacs Lisp, began in 1984.) The keyboard on lisp machines have the Ctrl key besides the space bar (similar to the position of Alt keys on PC keyboards), and Meta to the left of Ctrl . So, the Ctrl key is the primary modifier, and the Meta is secondary to Ctrl . This is why, the shortcuts for the most used commands in emacs involve the Ctrl key instead of the Meta key.

Examples:

The cursor movements: Ctrl + p , Ctrl + n , Ctrl + f , Ctrl + b , Ctrl + a , Ctrl + e

+ , + , + , + , + , + the cut paste undo { Ctrl + w , Ctrl + y , Ctrl + _ }

+ , + , + } kill-line 【 Ctrl + k 】

【 + 】 set-mark-command 【 Ctrl + Space 】

【 + 】 isearch-forward 【 Ctrl + s 】

Lisp Machine's keyboards died with Lisp Machines. Since the 1990s, the IBM PC Keyboards and its decedents became the most popular. The PC keyboard does not have Meta key but have Alt instead. The Alt is placed right beside the space bar, while Ctrl is placed far to the corner.

Emacs did not change its keybindings to adapt the PC keyboard. Emacs simply set the Alt to send Meta signal. Here's a excerpt from emacs manual:

Emacs also recognizes control characters that are entered using “modifier keys”. Two commonly-used modifier keys are (which is usually labelled as ), and (which is usually labeled as )(1). For example, `Control-a’ is entered by holding down the key while pressing `a'; we will refer to this as `C-a’ for short. Similarly `Meta-a’, or `M-a’ for short, is entered by holding down the key and pressing `a'. (1) We refer to <Alt> as <Meta> for historical reasons. From official emacs manual for version 23.2. (info "(emacs) User Input")

The heavy use of { Ctrl , Alt / Meta } combinations made emacs keyboard shortcuts painful, and the frequent need to press the far-away Ctrl key creates the Emacs Pinky syndrome.

Many emacs users have injured their hands with emacs, and emacs's Ctrl and Meta combinations are the most cited reasons as the major turnoff to potential users among programers. [see Famous Programers with Repetitive Strain Injury]

See also: Control Key and Capslock Key Positions in Old Keyboards.

The Choice of Keys

Emacs's shortcuts for cursor moving keys Keystroke Emacs Command Name Standard key Ctrl + p previous-line ↑ Ctrl + n next-line ↓ Ctrl + b backward-char ← Ctrl + f forward-char →

The shortcut's key choices are primarily based on first letter of the commands, not based on key position and finger strength or ease of pressing the key. For example, the cursor moving keys are scattered around the keyboard with positions that are most difficult to press. (these keys all together accounts for 43% of all commands executed by key) Of these, the most frequently used is Ctrl + n , which accounts for 20% of all shortcut calls, but is assigned to the letter n, positioned in the middle of the keyboard, which is one of the most costly key to press. Similarly, the second most used among these is the Ctrl + p , accounting for 16% of all shortcut command calls, is located in a position above the right hand's pinky, also one of the most costly key to press. [see Emacs Command Frequency]

emacs cursor keys on QWERTY

emacs cursor keys on Dvorak

The following is a quote from a prominent lisper Daniel Weinreb, who implement the first emacs in lisp EINE:

That's true. At the time [1976] Guy Steele put together the Emacs default key mappings, many people in the target user community (about 20 people at MIT!) were already using these key bindings. It would have been hard to get the new Emacs bindings accepted by the community if they differed for such basic commands. As you point out, anyone using Emacs can very easily change this based on their own ergonomic preferences. From [ emacs keybinding 2008-06-01 By Daniel Weinreb. At http://groups.google.com/group/comp.emacs/msg/0342e0bc1aa05c0d , accessed on 2012-09-08 ]

[see Lisp Programer Daniel Weinreb Died (1959 to 2012)]

Outdated Commands

A significant portion of emacs's major shortcuts (those with Meta + key or Ctrl + key ) are mapped to commands that are almost never used today. Some of these occupy the most precious space (For example, home row keys, or top row keys hit by index finger or middle finger.). Most programer who have used emacs for years never use these commands.

Some Statistically Infrequently Used Commands Occupying Easy Key Positions Command Name Keystroke digit-argument Alt + 0 to Alt + 9 negative-argument Alt + - move-to-window-line Alt + r prefix for highlighting Alt + s tab-to-tab-stop Alt + i (Prefix) Alt + g indent-new-comment-line Alt + j tmm-menubar Alt + ' back-to-indentation Alt + m tags-loop-continue Alt + , find-tag Alt + .

[see Emacs Key Layout Diagram]

Difficult Keystrokes for Frequently Used Commands

Some commands that are used by every emacs user many times every hour, such as {Open, Save, Close}, all require multiple keystrokes with the difficult Ctrl key.

Some Common Operations Standard Name Emacs Command Name Keystroke Open find-file Ctrl + x Ctrl + f Save save-buffer Ctrl + x Ctrl + s Close kill-buffer Ctrl + x k

Mode Specific Keys with Difficult Prefix Ctrl+c

By Emacs key policy, key shortcuts for each language mode's commands all have this difficult combination: Ctrl + c Ctrl + key . For example, here's some of the keys for C language mode.

C-c C-e c-macro-expand C-c C-a c-toggle-auto-newline C-c C-b c-submit-bug-report C-c C-c comment-region C-c C-d c-hungry-delete-forward C-c C-l c-toggle-electric-state C-c C-n c-forward-conditional C-c C-o c-set-offset C-c C-p c-backward-conditional C-c C-q c-indent-defun C-c C-s c-show-syntactic-information C-c C-u c-up-conditional C-c C-w subword-mode C-c C-\ c-backslash-region C-c . c-set-style C-c DEL c-hungry-delete-backwards C-c C-DEL c-hungry-delete-backwards C-c <C-backspace> c-hungry-delete-backwards C-c <C-delete> c-hungry-delete-forward C-c <C-deletechar> c-hungry-delete-forward C-c <deletechar> c-hungry-delete-forward

A Flaw in Keybinding Policy

Any major software, maintains a guide for the developers about the choices of keyboard shortcuts, so that the shortcuts will be consistent. Emacs has this in its Emacs Lisp manual: Key-Binding-Conventions (info "(elisp) Key Binding Conventions")

This guide, indicates that the only key space reserved for users to define, are the function keys F5 to F9 , and key stroke sequence starting with Ctrl + c followed by a single letter key.

This is a severe restraint to the utility of customized shortcuts. F5 to F9 are only 6 keys. The key sequence starting with Ctrl + c followed by a letter, is multiple keystrokes and rather a painful choice, and there are only 26 spaces there.

The function keys, F1 to F12 , are very good key space for user to define their own shortcuts. The digit key shortcuts, 0 to 9, are also good user space. These keys can be used with any combination of Ctrl , Alt , Shift . For example, a user might define them to insert various templates, headers/footers, a system of customized HTML/XML tags. Or, she might assign them to various special emacs modes such as dired, shell, ftp, email, calendar, calc, *scratch*, make-frame-command (Open a new window), insert signature.

It seems too drastic a policy, to limit user defined keys to only F5 to F9 , and key sequence of Ctrl + c followed by a single letter key.

Addendum: Keyboard Shortcut History in Computing Industry

Today, most commonly used keyboard shortcuts have been somewhat informally standardized. For example, Z X C V is for Undo Cut Copy Paste. O is for Open. S is for Save. P is for Print. F is for Find/Search. These are common conventions today in every application across Microsoft Windows, Macintosh, and Linux desktops.

These shortcut conventions are primarily brought about by Apple Computer Inc's Human Interface Guidelines and IBM's Common User Access in the 1990s.

In the early 1990s, DOS era software, each application has its own scheme of shortcuts. The following is a excerpt from the Wikipedia article on Common User Access:

CUA was a detailed specification and set strict rules about how applications should look and function. Its aim was in part to bring about harmony between MS-DOS applications, which until then had implemented totally different user interfaces. Examples: In WordPerfect, the command to open a file was F7 , 3 .

, . In Lotus 1-2-3, a file was opened with / (to open the menus), W (for Workspace), R (for Retrieve).

(to open the menus), (for Workspace), (for Retrieve). In Microsoft Word, a file was opened with Escape (to open the menus), T (for Transfer), L (for Load).

(to open the menus), (for Transfer), (for Load). In WordStar, it was Ctrl + K + O .

+ + . In Emacs, a file was opened with Ctrl + x followed by Ctrl + f (for find-file). Some programs used Escape to cancel an action, some used it to complete one; WordPerfect used it to repeat a character. Some programs used End to go to the end of a line, some used it to complete filling in a form. F1 was often help but in WordPerfect that was F3 . Ins sometimes toggled between overtype and inserting characters, but some programs used it for “paste”. Thus, every program had to be learned individually and its complete user interface memorized. It was a sign of expertise to have learned the UIs of dozens of applications, since a novice user facing a new program would find their existing knowledge of a similar application absolutely no use whatsoever.

If we take a survey of the market share of text editors (including IDEs) among professional programers (as defined by those who make a living by coding), then, it is my guess, that emacs from mid 1980s to early 1990s, has more than 50% of market share, but gradually declined. Today, perhaps less than 1% of professional programers use emacs. I think, part of the reason being that emacs has not modernized (not in the sense of being fashionable, but in the sense of keeping with hardware and software changes in the computing industry). The other major reason, is because emacs itself is not a IDE in a modern sense, and most programing development using compiled languages such as Pascal, C, C++, Java, C#, have moved on with IDE platforms integrated with these language's compiler application.

See also: Modernization of Emacs.

2008-07-15 Addendum: Thanks to Rainer Joswig for correction about the history of the lisp machine's keyboards. http://groups.google.com/group/comp.lang.lisp/msg/3b3dcdc52f507b02