Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having trouble getting the py-electric-backspace command to execute when I hit backspace at the end of a line of only spaces in python-mode. When I hit backspace it deletes individual spaces, not 4 at a time as it should be.

What confuses me is that if I do M-x py-electric-backspace, it performs the command correctly and tells me I could have invoked the command by using backspace:

You can run the command `py-electric-backspace' with <backspace>

I'm using python-mode.el version 6.0.10, and I've tried reducing my .emacs file to only the few lines required to load python-mode.el.

I'd like backspace to work properly in python-mode, but I don't even know where to start figuring out what's wrong. Any help would be appreciated.


I've added the following to my .emacs file:

(add-hook 'python-mode-hook
     (lambda () (define-key python-mode-map (kbd "DEL") 'py-electric-backspace)))

which seems to do the trick.

share|improve this question
up vote 2 down vote accepted

What is the output of C-h k <backspace>? My guess is that you are running in a terminal and you can't actually type <backspace>, since it gets changed by the terminal to DEL. Running in a GUI, or binding py-electric-backspace to DEL should fix it.

share|improve this answer
Thanks! I think this might be a bug in the latest python-mode.el (I've reported it here but this works in the meantime. – Noah Jul 20 '12 at 14:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.