Why does the Backspace key invoke help?
The Backspace key (on most keyboards) generates ASCII code 8. C-h sends the same code. In Emacs by default C-h invokes help-command. This is intended to be easy to remember since the first letter of ‘help’ is ‘h’. The easiest solution to this problem is to use C-h (and Backspace) for help and DEL (the Delete key) for deleting the previous character.
For many people this solution may be problematic:
They normally use Backspace outside of Emacs for deleting the previous character. This can be solved by making DEL the command for deleting the previous character outside of Emacs. On many Unix systems, this command will remap DEL:
bashstty erase '^?'The user may prefer the Backspace key for deleting the previous character because it is more conveniently located on their keyboard or because they don’t even have a separate Delete key. In this case, the Backspace key should be made to behave like Delete. There are several methods.
Some terminals (e.g., VT3## terminals) and terminal emulators (e.g., TeraTerm) allow the character generated by the Backspace key to be changed from a setup menu.
You may be able to get a keyboard that is completely programmable, or a terminal emulator that supports remapping of any key to any other key.
You can control the effect of the Backspace and Delete keys, on both dumb terminals and a windowed displays, by customizing the option
normal-erase-is-backspace-mode, or by invoking M-x normal-erase-is-backspace. See the documentation of these symbols (see Where can I get documentation on Emacs Lisp?) for more info.It is possible to swap the Backspace and DEL keys inside Emacs:
emacs-lisp(keyboard-translate ?\C-h ?\C-?)This is the recommended method of forcing Backspace to act as DEL, because it works even in modes which bind DEL to something other than
delete-backward-char.Similarly, you could remap DEL to act as C-d, which by default deletes forward:
emacs-lisp(keyboard-translate ?\C-? ?\C-d)See How do I swap two keys?, for further details about
keyboard-translate.Another approach is to switch key bindings and put help on C-x h instead:
emacs-lisp(global-set-key "\C-h" 'delete-backward-char) ;; overrides mark-whole-buffer (global-set-key "\C-xh" 'help-command)This method is not recommended, though: it only solves the problem for those modes which bind DEL to
delete-backward-char. Modes which bind DEL to something else, such asview-mode, will not work as you expect when you press the Backspace key. For this reason, we recommend thekeyboard-translatemethod, shown above.Other popular key bindings for help are M-? and C-x ?.
Don’t try to bind DEL to
help-command, because there are many modes that have local bindings of DEL that will interfere.
When Emacs runs on a windowed display, it binds the Delete key to a command which deletes the character at point, to make Emacs more consistent with keyboard operation on these systems.
For more information about troubleshooting this problem, see If DEL Fails to Delete in The GNU Emacs Manual.