Sometimes I discover an Emacs feature after an accidental keystroke. If I can remember the keystroke, I'll invoke the keystroke help (C-h k) to learn about it. Or sometimes the prompt in the mode line will suggest the function's name.
Today, the keystroke was M-z
, which is bound to the function
zap-to-char.
It seems to be ideal if, like me, you doze briefly while typing a senteeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Oops, there I go again!
To fix that I can just press M-- M-z t
to delete all the trailing "e" characters.
Note that M--
is invoked by holding down the Alt key
while pressing hyphen. It defines a negative prefix argument,
which instructs zap-to-char to "go backward," deleting all
characters from point to the specified character ("t"). I'm not
sure how or why you'd want the default "forward" behavior.
What accidental keystroke have you discovered recently?
I often use zap to char or zap up to char when replacing the contents of a string or a parenthetical note, or when rewording part of a phrase or a sentence.
ReplyDeleteI can see that it would be useful for parenthetical or quoted phrases. It would be "targeted" since the "char" would be somewhat unique. Thanks for that suggestion!
DeleteI zap quite often but usually via avy, https://github.com/abo-abo/avy. This allows me to zap to the precise character I want, because zap-to-char is indeed often not precise enough.
ReplyDeleteThanks for the recommendation for avy, Rens -- it looks very useful!
Delete