Emacs vs vi: How to Compute a Keybinding's Efficiency?

keys on keyboard are precious. There are only a few good spots, and ten times more commands.

so, i have now one key, i want to set it to one frequently used command. Let's say the key is Tab ↹, and it's positioned either under your thumb or someplace very easy to hit (such as Caps Lock or Return ↩ position on PC keyboard)

① set it to one very frequently used command. (For example, keyword completion)

② set it as a lead key of key sequences for a set of commands. (For example, as a lead key of a key sequence for all commands that doesn't have a dedicated single key keybinding.) (for why we want a key sequence, instead of a chord key such as 【Ctrl+x】, see: Banish Key Chords.)

the question is, which is more efficient?

such a precious key. If you set it to one most used command, how wonderful, just one single key right under your thumb!

O, but, there are 10 other commands, although less frequently used than your completion, but these are also frequently used, and when counting their frequency of use together, might beat the completion command.

But if you use tab as in 【Tab ↹key】 for these commands, but then you lose your so super convenient single key for the super important completion command! what can you do??

well, let's just use another convient key on keyboard. NO, the point is, for each 1 convenient key, there are 10 commands wanting to use it. Can't fit 10 pigeons in 1 hole, the pigeon hole principle!

so, which is more efficient?

let's say the key is Tab ↹.

let's say that one frequently command is keyword completion, but let's just call it xCmd.

Let's say the set of commands i might want to use Tab ↹ is yCmds, and yCmds[1] is first one, yCmds[2] is second one, etc, up to yCmds[n].

the short answer is:

keybinding score of a set of keybindings is the sum of each's score.

and how to compute a keybinding's score? it's this:

frequency[cmd] * key_ease_score[get_key[cmd]]

so, back to our question, of using Tab ↹ for completion is better or use Tab ↹ for a bunch of commands. It can be computed this way:

so, in order to know, you actually have to come up with the keys for each of yCmds[i] in order to tell.

How to Compute a Keybinding's Efficiency?

let's go about this scientifically.

in general, efficiency can be computed thus:

let freq[cmd] be a function that returns the frequency of a command named “cmd”. It returns a value from 0 to 1. (like percentage) It is the ratio of the count of cmd call over the count of all command calls (during a period, say, a month. (and, let's say it's derived from the average of 100 person's command log of emacs))
〔➤ Emacs's Command Frequency Statistics〕

then, we need to assign a score for each physical key on keyboard. Each key should have a ease-of-press score, from 0 to 1. With 1 meaning the easiest. (the Space bar key would have score of 1. The ⌫ Backspace key would have a very low score. (also, note that this scoring of keys is dependent on specific physical keyboard layout. For example, even standardish PC keyboard from
Microsoft Keyboards or
Logitech Keyboards
differ slightly in their physical key layout a bit, such as the exact position and the size of Alt ＆ Ctrl keys, shape of Return ↩ key.))

for simplicity, let's assume this fairly standard keyboard and with QWERTY layout:

assigning scores to keys is a bit hard. But basically, home row keys would have high score, keys using index finger and pointing finger would have higher score than using ring finger or pinky finger. And keys on top row usually have higher score than bottom row.

this has been studied before. For example, here's what the Workman layout designer OJ Bucao's thought about key score.

we need to give a score for all keys, including
{Return ↩Caps LockAltCtrlCtrlTab ↹F1 …}.

how to derive the key score? One way is by one-person's experience and logical analysis, such as OJ Bucao has done here. Another way is to let a group of keyboard layout designers to come up with a score that we all agree on.

once we have a score of keys, then we can compute the efficiency of a keybinding.

it is this:

freq[cmd] * key_ease_score[key]

what about key chord such as {【Ctrl+x】, 【⇧ Shift+t】} or key sequences such as {【Caps LocktCaps Lock】, 【Altec】}?

score of keyboard shortcut involving chord such as 【Ctrl+x】 can be computed as score of Ctrl and score of x multiplied by some multiplier factor. Something like: