One of the most annoying problems that newcomers experience with Emacs is that
they often press
C-z out of habit when they want to undo something.1
C-x C-z), however,
is bound to the command
suspend-frame that works a bit differently than undo:
Do whatever is right to suspend the current frame. Calls
suspend-emacsif invoked from the controlling tty device,
suspend-ttyfrom a secondary tty device, and
iconify-or-deiconify-framefrom a graphical frame.
In short - in a terminal this will suspend Emacs and in a GUI it will minimize Emacs.
Both are annoying outcomes, if you didn’t aim for them. So, what can we do about it?
Given the command is already bound to the “safer”
C-x C-z as well, I think it’s perfectly fine to just unbind it from
(global-unset-key (kbd "C-z"))
Or you can just bind it to
undo for good measure and make learning Emacs a bit easier for you:
(global-set-key (kbd "C-z") #'undo)
Given that I never use neither
C-x C-z I prefer to rebind both of them to
undo. So, how do you feel about those keybindings? Do you do something about them?
That’s all I have for you today. Keep hacking!
I’ve been using Emacs for almost 20 years and I still press
C-zby mistake, although for a different reason. I often the use the keybinding
C-c C-zand sometimes by mistake I press
C-x C-z. ↩