One thing that’s been a thorn in my side since I switched over to Emacs was that pesky Ctrl+Z combination that suspends the Emacs. Initially I wasn’t even sure how to get it back so I’d have to kill the process to release the file lock and launch Emacs again. It was a huge pain and I was losing work because of it. Eventually I found out that simply typing “fg” into the console would bring it back to the foreground and that made it a little less annoying. Though I still found myself doing it about 10 times a day as I often miss the X when initiating any Ctrl+X commands, or sometimes I habitually hit Ctrl+Z to undo instead of Ctrl+X Shift+U. So if this bugs the crap out of you like it did with me, here is how you can unbind the key and (optionally) bind that key sequence to Undo
Add the following to your .emacs file:
;; Unbind Pesky Sleep Button (global-unset-key [(control z)]) (global-unset-key [(control x)(control z)])
If you’d also like to bind the undo function to this key as it is now free to use, add the following lines as well:
;; Windows Style Undo (global-set-key [(control z)] 'undo)
Now save and close your .emacs file and then if you have any open Emacs sessions close them and restart, you should now be able to code without randomly shutting down Emacs.
A seasoned Senior Solutions Architect with 18 years of experience in technology design and implementation. Renowned for innovative solutions and strategic insights, he excels in driving complex projects to success. Outside work, he is a passionate fisherman and fish keeper, specializing in planted tanks.