Emacs – Disable Suspend Button

June 23, 2010

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.

Only registered users can comment.

  1. You should also look into cua-mode which will give you more traditional copy/paste keybindings. It also has a column editing mode that is insanely helpful.

  2. @rho – That’s unfortunate 🙁 I haven’t really been using emacs lately (change of jobs forced me into using Visual Studio at work). I’m sure there must be a solution to the problem though 🙂

  3. @FettesPS
    Thats terrible! Visual Studio! damn they don’t understand the power of emacs!
    I would quit my job i have to use the Windows ever!

    but you should try out emacs24 its just awesome! its rising again!

  4. Oh man, THANK YOU!!! Those shortcuts were driving me bananas. OCode snippet is working perfectly fine for me, too (I’m running Emacs 25.3.1, OpenBSD 6.2).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.