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

By Xah Lee. Date: ,

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>") 'ergoemacs-backward-block) ; page up key
(global-set-key (kbd "<next>") 'ergoemacs-forward-block) ; page down key

(global-set-key (kbd "<home>") 'ergoemacs-backward-open-bracket)
(global-set-key (kbd "<end>") 'ergoemacs-forward-close-bracket)

you can get the command definitions in ergoemacs-mode 〔➤see ErgoEmacs Keybinding〕 or at Emacs: Move Cursor to Bracket/Quote.

O Why? U Weirdo!

in pursuit of utter efficiency.

here's the rational for this design. Page up/down is for quickly moving to parts of a document. Usually, the mouse wheel does a better job. Mouse wheel is better, because it is faster and you have better control.

for longish document less than 20-screenful, the mouse wheel with acceleration is faster. For pages longer than 20 screenful, holding down the page key is easier and faster. But such long pages are comparatively rare.

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

See also:

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 ⇟ Page Down 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.

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 130 keys (counting app launch keys and media 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, and 5 launch app keys, totaling about 35.

Of the 35 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's 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.

you need to try it for a week.

Banish Key Chords

See: Banish Key Chords.

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs