Xah Lee, 2007-07, ..., 2009-01
Emacs's default keybindings are very ergonomically painful, for several reasons. (For detail, see: Why Emacs's Keyboard Shortcuts Are Painful.) This page shows a emacs package that makes your emacs use a new shortcut set. This shortcut set is designed based on ergonomic principles, using emacs command call statistics, similar to how Dvorak layout is designed.
Note: This project is mirrored on Google Code, at http://code.google.com/p/ergoemacs/.
Here's the outline of how this design is arrived.
Statistics of emacs commands are compiled from emacs users, and are listed by frequency of use. The top about 30 ones, are given a keyboard shortcut.
To assign the key position, the following rules are used. The rules are listed roughly in order of priority:
The design is based on finger positions, not on first letter of command names. The shortcut set is the same for QWERTY and Dvorak. The ease of remembering what commands are on what keys are based on grouping and positioning. For example, cursor movings are all right hand, text changing are all left hand, moving or deleting to the left/right have keys that are place left and right together, and similar for up/down (by screen or to beginning/end of file). Undo, Cut, Copy, Paste are the familiar row Z X C V.
In this design, only the Meta+‹key› space is used. Some Meta-shift is used too. Ctrl+‹key› space is not used except 7 standard keybindings (Open, Close, Save, Save As, Print, Select All). The operation and consistency of emacs are not unaffected.
← backward-char ←w backward-word ←¶ backward-paragraph |← move-beginning-of-line → forward-char →w forward-word →¶ forward-paragraph →| move-end-of-line ↑ previous-line ↓ next-line |
▲ scroll-down (page up) ▼ scroll-up (page down) |◀ beginning-of-buffer ▶| end-of-buffer isearch← isearch-backward isearch→ isearch-forward |
⌦ delete-char ⌦w kill-word ⌦| kill-line ⌫ delete-backward-char ⌫w backward-kill-word |⌫ kill-line-backward copy kill-ring-save ✂ kill-region paste yank paste↑ yank-pop M-x execute-extended-command |
Shown with Dvorak key labels: Ergoemacs Dvorak.
Download at: http://code.google.com/p/ergoemacs/downloads/list.
The following table are commands that are statistically not often used. They no longer have a keyboard shortcut. If you need them, you will need to bind them. (there are a lot empty space now in “Ctrl+‹key›” space.
| Emacs Commnands | Qwerty | Dvorak |
|---|---|---|
| Cursor Moving | ||
| backward-sentence (Alt+a) | ✗ | ✗ |
| forward-sentence (Alt+e) | ✗ | ✗ |
| move-to-window-line (Alt+r) | ✗ | ✗ |
| center-line (Alt+s) | ✗ | ✗ |
| Text Changing | ||
| kill-sentence (Alt+k) | ✗ | ✗ |
| zap-to-char (Alt+z) | ✗ | ✗ |
| indent-new-comment-line (Alt+j) | ✗ | ✗ |
| transpose-words (Alt+t) | remain | ✗ |
| Other | ||
| facemenu prefix (Alt+g) | ✗ | ✗ |
| eval-expression (Alt+:) | ✗ | ✗ |
| abbrev-prefix-mark (Alt+-) | remain | ✗ |
| tmm-menubar (Alt+') | ✗ | ✗ |
| find-tag (Alt+.) | remain | ✗ |
| tags-loop-continue (Alt+,) | remain | ✗ |
| tab-to-tab-stop (Alt+i) | ✗ | ✗ |
| dabbrev-expand (Alt+/) | ✗ | remain |
Most emacs's default shortcuts in the Ctrl+‹key› space are removed for Kicking the Habit. If you wish them to be still available, you can uncomment the code in the elisp file.
For convenience, the following standard shortcuts are also made available:
| Standard name | Key press | Emacs command name |
|---|---|---|
| Open New File | Ctrl+n | new-empty-buffer |
| Open | Ctrl+o | find-file |
| Close | Ctrl+w | close-current-buffer |
| Save | Ctrl+s | save-buffer |
| Save As | Ctrl+Shift+s | write-file |
| Ctrl+p | print-buffer | |
| Select All | Ctrl+a | mark-whole-buffer |
| Standard name | Key press | Emacs command name |
|---|---|---|
| Next Window | Alt+` | next-frame-command |
| Previous Window | Alt+~ | previous-frame-command |
| Next Tab | Ctrl+PageDn | next-user-buffer |
| Previous Tab | Ctrl+PageUp | previous-user-buffer |
| - | Ctrl+Shift+PageDn | next-emacs-buffer |
| - | Ctrl+Shift+PageUp | previous-emacs-buffer |
The following are new commands in ergoemacs. They combine several emacs commands that each has a keyboard shortcut. Now, you have one single command with one single shortcut, that does what you want depending on context.
| Name | Description |
|---|---|
| shrink-whitespaces | Calls either just-one-space or delete-blank-lines depending on context. |
| compact-uncompact-block | Calls either fill-paragraph or unfill-paragraph depending on context. |
| toggle-letter-case | Toggles letter case of current word or region. It combines capitalize-word, downcase-word, upcase-word and the -region versions. |
| move-cursor-next-pane | Identical to “(other-window 1)” |
| move-cursor-previous-pane | Identical to “(other-window -1)”. |
On Mac OS X, “Cmd+h” is Hide and “Cmd+Shift+q” is Log Out. If your Meta is Cmd, then the Mac behavior will not be available because ergoemacs uses these keys. If you wish to have the Mac behavior, put the following in your emacs init file:
(setq mac-pass-command-to-system t)
On Microsoft Windows, “Ctrl+Shift” or some other combination may switch your Input Language or Keyboard Layout. You can disable this, or change the shortcut to something else. Go to your Windows Control panel, keyboards, Advanced Key Settings tab, then press the button “Change Key Sequence...”. (This describes Windows Vista, other Window versions are similar.)
Many modes define their own keybindings. When a mode's special bindings conflict with ones in your global keymap, it'll override it. Vast majority of modes do not use the “Meta+‹key›” space. (most mode-specific bindings happen in the “Ctrl+c Ctrl+‹key›” space by convention.)
Ergoemacs is tested to work in all major language's modes. (if you find it otherwise, please let me know) If you downloaded some new mode off the net, you may need to reclaim some keybinding. See: How To Reclaim Keybindings.
On the subject of keyboarding ergonomics, a user may wonder whether switching from QWERTY to Dvorak provides a better improvement than switching from a lousy to better keyboard shortcut layout. (Assuming that he does only one of the above.)
Of my Emacs Commands Frequency study, 43% of key strokes involves data entry (that is, calling the commands “self-insert-command” (typing) and “newline” (pressing return), while the rest 57% are calling all other commands. This seems counter-intuitive, because one might think typing should probably be the bulk of activity and moving cursor and deleting text or other commands are only done few times per minute.
This data suggests that better shortcut placement is more important than better placement of letter keys for programing.
If you are a long time emacs user, you may find it painful to adopt this setup. This difficulty is nothing special. It's the same difficulty when you switching to dvorak after years of qwerty. Basically, it's about changing muscle memory.
For some tips and elisp code for gradual adoption, see: http://code.google.com/p/ergoemacs/wiki/adoption.
See Testimonial for Ergoemacs.