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:
stty erase '^?'
normal-erase-is-backspace-mode, or by invoking M-x normal-erase-is-backspace. See the documentation of these symbols (see Emacs Lisp documentation) for more info.
(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
Similarly, you could remap DEL to act as C-d, which by default deletes forward:
(keyboard-translate ?\C-? ?\C-d)
See Swapping keys, for further details about
(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
which bind DEL to something else, such as
not work as you expect when you press the Backspace key. For this
reason, we recommend the
keyboard-translate method, shown
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 21 or later 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.