An Accidental Ode to MSWord Hotkeys

An Accidental Ode to MSWord Hotkeys

This was triggered by the discussion on news.ycombinator.com/item?id=5305055.

I feel that much of the perceived difference between modefulness and modelessness is in your head (doesn't make it less real, I admit). Look, are you familiar with the concept of a hotkey sequence? They're the most visible in Emacs, where many commands are bound to a sequence such as C-x C-s.

Everything we do on a keyboard is part of a sequence. In Vim, you can type :wqa to execute a command, and if someone made a similar binding in Emacs, it would be represented in their notation as S-; w q a, and more importantly, it would feel different to many people. Because in Vim, : makes you enter a state where you can type anything you want in a free-input field, and in this case you type wqa. In Emacs, pressing S-; will make the minibuffer display S-; while nothing happens, indicating that you've begun a hotkey sequence. As you press each key, they'll show up: S-; w q a … It feels like you're in the same state throughout, where Emacs is doing nothing and waiting for you to reach a sequence that is bound to a command. In particular, you feel constrained. In the Vim equivalent, you can backspace whereas in Emacs if you press the wrong key you have to re-do the sequence.

But you're ultimately doing the same thing with your fingers. Someone recording your fingers wouldn't know if you were executing an Emacs command, a Vim command, or merely typing ":wqa" into the body of a blog post.

When you type the word "hi", you are executing the sequence of pressing the h key followed by the i key. I grant this is a silly example, but I need to show that every keystroke comes in sequences. Sequences are the universe, the backdrop of everything that happens during keyboard input.

Modern editors typically have hotkey sequences consisting of a single step. Obviously, a single hotkey is always better than two in a sequence. By the same token, two hotkeys are better than three, and so on. You want the fewest number of steps in the sequence, for convenience. Cheers to modern editors!

This is complicated by the question of which hotkeys you put in the sequence. If they are single letters like w q a, fine! If they are C-c C-x p, not so good. The latter looks like three keystrokes but is four, or five if you count having to release the Ctrl key before pressing p, which I find at least as annoying as having to press it in the first place.

Now, back to modern editors: they typically have hotkey sequences consisting of a single step. But what hotkeys? Almost always a combination like Ctrl-F, which is two keystrokes minimum.

Given that they're modeless, of course they have to do it this way. And it's not so bad. The thing about Vim Normal mode is that single-hotkey commands don't even need modifiers, you can just press f, no Ctrl.

The drawback is that you have to enter a "mode", which sounds weird.

To get around this, I will describe another basic concept of keyboard input, which has many names but that I'll call a hydra. A hydra is a many-headed beast of Greek myth, that grew new heads whenever one was cut off. It's also a way of making hotkey sequences more persistent. For example, suppose that you wanted to execute the following commands:

C-c C-x p
C-c C-x l
C-c C-x a

Lot of work, right? But, if the sequence C-c C-x is a hydra, then what you have to type is

C-c C-x p l a

That is, the first parts of the sequence don't have to be retyped.

The way hydras are typically implemented in Emacs is that they're nonpersistent (compared to a Vim mode, see later). As soon as you hit some key (let's say r) that isn't bound to anything in the hydra, it exits the hydra and does what that key would have done instead, i.e. instead of it trying to execute the equivalent of C-c C-x r you simply type the letter r onscreen. The hydra is exited trivially, unlike modes in Vim that have to be exited with the ESC key.

Now the meat of the topic. All that a mode is, is a type of hydra. The Vim Normal mode is a hydra that starts with ESC, and it's very broad, having many different keybinds coming after ESC. We might say that the hydra has one head for every key on your keyboard: there are none undefined. It's a persistent one, as it's not easy to exit. The escape hatch is the i key, which instead puts you in the Insert mode hydra (and doesn't insert the letter "i": it's a whole keystroke merely to change mode and do nothing more).

If you like to view it this way, all editors are constantly in a hydra, just one that doesn't need to be entered with any key beforehand. Modeless editors aren't modeless, they have one mode.

Now think about this: What is easier to press, Ctrl-F or Ctrl then F? Is it easier to press the D key and the F key at the same time, or to press them in sequence?

YMMV, but many feel that pressing two keys in sequence is more comfortable than two keys at the same time.

So over of pressing d and f together, we always prefer the sequence d and then f. What if the reason you do this is that 'd' puts you in a different mode, where the 'f' key will do what you want? Does it make a difference? In the Vim paradigm, yes: you will also have to exit that mode when you're done. Then it can be preferable to just press a chord such as Ctrl+F and not think about entering and exiting modes.

Suppose the mode wasn't persistent? I.e. suppose by pressing d you enter the mode, then by pressing f, you execute that command and return to the mode you were in previously.

Well. Then it's not a mode as most would define it, just a hotkey sequence. (It can be a hydra though: hydras may have both persistent and non-persistent heads, a mixture of those that grow back and those that don't)

If you want to take the classification to the extreme, each hotkey in a hotkey sequence is a small mode, a non-persistent one, wherein the next hotkey will do something it wouldn't have done otherwise. Emacs has hundreds or thousands of these small modes while Vim has three big modes. Most editors have one (by virtue of rejecting hotkey sequences altogether).

Microsoft Word is actually an exception. If you're a whiz with hotkeys there, you know what I mean: they use hotkey sequences (all of which start with Alt), though never with modifiers. It's like the best of Vim and Emacs: the modes are non-persistent and automatically exit (unlike Vim), and they don't need you to hold down the Ctrl key either (unlike Emacs). The only way to improve on this would be make some of those sequences into hydras, and correct me if I'm wrong, but I think Word has done that too.

Word is bad in so many ways, but it seems the keyboard input was competently designed.

Anyway, I hope modes don't feel weird now.

Keyboard design

What links here

  • 2023-09-13
Created (7 years ago)