Emacs Keybinding Efficiency: Page Up/Down and Pigeon Hole Principle

By Xah Lee. Date: . Last updated: .

this page discuss a better use of page key and home/end keys for programers.

in emacs, now i have set:

here's the code:

(global-set-key (kbd "<prior>") 'xah-beginning-of-line-or-block) ; page up key
(global-set-key (kbd "<next>") 'xah-end-of-line-or-block) ; page down key

(global-set-key (kbd "<home>") 'xah-backward-left-bracket)
(global-set-key (kbd "<end>") 'xah-forward-right-bracket)

get the command definitions at:

O Why?

in pursuit of utter efficiency.

Mouse wheel with accelerated scroll (in macOS and Microsoft Windows) is faster, more efficient, more precise, then using PageUp PageDown keys to page up/down.

Note: it's important you have mouse wheel acceleration on. It makes a major difference.

See:

Accelerated Mouse Wheel is Superior to Page Up/Down Keys

Also, mouse wheel gives you fine control. You can scroll by a few lines. Paging can't do. For programers working on computer source code, this is especially nice.

This makes sense, because mouse wheel is a device that you can smoothly control the firing rate, at 1 hit per second to some 20 hits per second. But a button, such as the PageDown key, you either sweat to press it multiple times a second, or hold it down and maintain a constant ~25 per second.

but mouse is far away?

Not if you use left hand for it, or use a Tenkeyless Keyboard or Truly Ergonomic Keyboard. On standard PC keyboard, the page up/down key is also away from the main section. But what about emacs default key Ctrl+v for page down and Alt+v for page up? The problem here is then you got key chords, harder to press.

[see Function Key vs Key Chord, Which is Healthier, Which is Faster?]

here's a pigeon hole principle about keybinding:

You have 100 pigeon holes, but you have 200 pigeons. Which pigeon should have a home?

the pigeon hole here are nice single keys. The pigeons are emacs commands.

On a keyboard, there are about 100 keys. However, most of them already has a important purpose, such as letter keys, digit keys, Enter, Esc, Tab, Page up/down, arrows. The keys that are free, are about 12 function keys, and 17 keys on numpad, totaling about 30.

Of the 30 free keys, you need to jam about 100 to 200 commands. For example, look at:

Both mouse wheel and page key are for quickly moving to parts of document. So, having one pigeon occupy 2 holes is not nice. Between the two, mouse wheel is better, thus the page key must be saved for another command.

so, mouse wheel is for paging. What to do with the page up/down key? A better function for them is to move cursor by blocks of text. A block is text separated by blank lines. This is extremely useful in computer source code, any language.

What is Up with the Home/End Keys?

In text editors, the purpose of {Home, End} keys is either one of:

For moving to begin/end of line, it's a very frequently used in text editing or terminal, thus inconvenient to move hand away from main section. Better to use hotkeys on the main section.

For moving to begin/end of document, it's relatively rarely used. Most of the time, the page key or mouse wheel does it. So, again, you don't want 1 pigeon occupy 2 holes. The {Home, End} keys are nice single keys. It'd be a waste to use them for rare functionality.

So, i let them move cursor to prev/next occurrence of any brackets (){}[]. Again, this is extremely nice for source code.

both of these functionality are in ErgoEmacs, and i use them heavily, every minute, for the past 3 years, but now i assign them SINGLE keys.

[see ErgoEmacs Keybinding: a Ergonomics Based Keyboard Shortcut System]

you need to try it for a week.

Ban Key Chords

Ban Key Chords

2017-06-02 Addendum

2017-06-02, principles discussed on this page are implemented in Emacs: Xah Fly Keys.