Next: How do I swap two keys?, Previous: How do I set the X key “translations” for Emacs?, Up: Key bindings [Contents][Index]
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 Where can I get documentation on Emacs Lisp?) 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 delete-backward-char
.
Similarly, you could remap DEL to act as C-d, which by default deletes forward:
(keyboard-translate ?\C-? ?\C-d)
See How do I swap two keys?, for further details about keyboard-translate
.
(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 as view-mode
, will
not work as you expect when you press the Backspace key. For this
reason, we recommend the keyboard-translate
method, 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.
Next: How do I swap two keys?, Previous: How do I set the X key “translations” for Emacs?, Up: Key bindings [Contents][Index]