On day 2, I talked about command discoverability and the pointlessness of memorizing key combinations. I also talked a bit about
global-set-key on day 2 and keymaps on day7. This is an additional point to the topic.
Many default key configurations are transferable. For example, “dired-like” modes have similar key configurations (e.g. “g” for
revert-buffer). I usually think along the same line when I assign my keys. I have a motto: For any given mode, find out the most frequently used command (besides cursor movement) and then assign the key combination
C-q to that command.
You might ask: why
C-q is close to
C-a, both are frequently used key combinations. Second, I actually don’t understand what the command originally mapped to
quoted-insert) does. Okay, I admit that I am lying. I know what
quoted-insert does, but I actually don’t use the command.
Okay, okay, I am lying again. I actually read it somewhere that someone binds
ess-eval-region-or-line-and-step. The Mandela Effect kicks in. I thought that I read it somewhere in the Emacs Speaks Statistics Config Share Space and specifically from Kara Woo’s configuration. But I was wrong. Actually, I “cargo-culted” key chords from her configuration (see day 7). Upon some searching on Github, I can only see that Github user mt-christo assigns
ess-eval-region-or-line-and-step. I probably copied it from there.
By ESS’ default,
C-RET maps to
ess-eval-region-or-line-and-step. And it is similar to RStudio. But
C-RET isn’t ideal because it clashes with many things 1. And I really needed to remap it. And
C-q is my choice.
I want to take this opportunity to praise the ESS team for coming up with the command
ess-eval-region-or-line-and-step. It is an extremely effective command. For a long time, I used
C-c C-r) and
C-c C-j). But the step part of the command
ess-eval-region-or-line-and-step makes it wunderbar. It jumps to the next line of code automatically! So, I can just repeatedly press
C-q when I want to eval a whole page of R code one line at a time.
eval-in-repl by Kazuki Yoshida et al provides the same
ess-eval-region-or-line-and-step experience to many different languages. For example, I can have the same experience to eval emacs lisp code in
ielm. My key combination, well, of course is also
(use-package eval-in-repl :bind ( :map emacs-lisp-mode-map ("C-q" . 'eir-eval-in-ielm) :map lisp-interaction-mode-map ("C-q" . 'eir-eval-in-ielm) :map Info-mode-map ("C-q" . 'eir-eval-in-ielm)) :config (require 'eval-in-repl-ielm) :init (setq eir-ielm-eval-in-current-buffer t) )
Because my brain has been hardwired to pressing
C-q, I add
C-q to many modes. For many modes, there are just a few operations; directional operations and maybe one or two additional commands. For those modes, I just leave the directional operations intact and then the most important commands to
On day 3, you see that I assign
vterm-send-next-key-verbose. On day 22, I assign
C-q to toggling the cursor in
A normal emacs installation comes with a few thousand commands. By homogenizing the key combination like this, the complexity of emacs is reduced and hence the cognitive load to use it. Also, it makes the emacs experience truly my own.
In some terminal emulators,
RET are the same. Therefore for a long time, I didn’t know
ess-eval-region-or-line-and-step exists. ↩
And for the sake of completeness,
C-c C-c is to cancel the filter in
deft. So I can quickly search and cancel a search by
C-q some keywords and then
C-c C-c; rather than using sluggish interface. ↩
BTW, if one doesn’t think
C-q makes any sense, it is better put this in the “home row”. Among a,s,d,f, I think it is better to make
C-d the “Isildur’s Bane” (if you don’t use
delete-char, of course; I don’t actually). ↩