I used global-set-key for a test and now I overwrote an important emacs keybinding... reddit / emacs ---------------------------------------------------------------------- Dumb-Ptr · 2022-01-24 17:04 In particular, I overwrote C-h, not essential but I want it back to be the help command... I used (global-set-key (kbd "C-h") 'evil-window-left) in my init.el file, how do I undo this? ---------------------------------------------------------------------- mina86ng · 2022-01-24 17:15 Remove the line from `init.el` and restart Emacs. By the way, everyone knows that proper binding for `C-h` is `(global- set-key "\C-h" [(backspace)])`. ---------------------------------------------------------------------- Dumb-Ptr · 2022-01-24 17:54 ah sorry, dumb question. I just re-evaluated the init.el file instead of restarting emacs... ---------------------------------------------------------------------- BettaGeorge · 2022-01-24 18:06 Out of curiosity, why should it be backspace? Some kind of emacs meme I've been missing out on? ---------------------------------------------------------------------- oantolin · 2022-01-24 18:54 Backspace and `C-h` are the same character in a sense, some terminals don't distinguish them, for example. You can read about it [in the man ual](https://www.gnu.org/software/emacs/manual/html_node/efaq/Backspac e-invokes-help.html). ---------------------------------------------------------------------- 7890yuiop · 2022-01-24 20:04 Run a separate new instance: * `emacs -Q` * `C-h k C-h` Back in the 'broken' instance: * `M-: (global-set-key (kbd "C-h") #'THING)` where THING is what you learned from the other instance. ---------------------------------------------------------------------- BettaGeorge · 2022-01-24 20:07 Thanks! ---------------------------------------------------------------------- kiki_lamb · 2022-01-24 20:42 > By the way, everyone knows that proper binding for C-h is (global- set-key "\C-h" [(backspace)]). Yes. ---------------------------------------------------------------------- kagevf · 2022-01-25 03:32 This was the answer I was looking for, but when I tried it emacs waits for the "next part" of the command, I guess since C-h is a "prefix" (not sure of the correct terminology). I tried C-h RET but that's it's own command combo. Any other ideas similar to your original suggestion? ---------------------------------------------------------------------- 7890yuiop · 2022-01-25 06:42 Sorry -- that was dumb of me. For a prefix binding I think the easiest thing would be `C-h b` to list all bindings for the current buffer, and then isearch in that for `C-h`. That gives us: Global Bindings: key binding --- ------- C-h help-command Which tells us the command, and that it's in the global keymap, so we can then do this: (global-set-key (kbd "C-h") 'help-command) or if it wasn't the global keymap, we'd use: (define-key KEYMAP (kbd "C-h") 'help-command) --- If it's useful to know, `help-command` is a so-called "prefix command" which means that the symbol's *function* slot contains a keymap. You can see that with `(symbol-function 'help-command)` ---------------------------------------------------------------------- kagevf · 2022-01-25 08:09 Wow, thank you ... very useful information! Thanks to lossage, I see that C-h b is " C-h b \[describe-bindings\]" which apropos describes as "Display a buffer showing a list of all defined keys, and their definitions." I'll need to learn more about what keymap is and how it works ... I'll go through [http://www.gnu.org/software/emacs/manual/html\_node/elisp/ Keymaps.html](http://www.gnu.org/software/emacs/manual/html_node/elisp /Keymaps.html) maybe tomorrow ... ---------------------------------------------------------------------- 7890yuiop · 2022-01-25 11:09 https://www.masteringemacs.org/article/mastering-key-bindings-emacs is a really good overview. I recommend reading that to begin with. ---------------------------------------------------------------------- kagevf · 2022-01-25 15:16 That was a great read! Still going through the comments which have useful bits of info as well ... thank you! :) ---------------------------------------------------------------------- _pkal · 2022-01-25 16:44 It was the [traditional binding](https://web.archive.org/web/201107230 33542/http://www.burlingtontelecom.net/~ashawley/gnu/emacs/doc/emacs- 1978.html#Preface) for backspace, and allegedly [goes back](https://unix-kb.cat-v.org/) to [TOPS-20](https://en.wikipedia.org/wiki/TOPS-20), as the ASCII code for backspace is the same as `^H` (if you open the [ascii(7)](https://man7.org/linux/man-pages/man7/ascii.7.html) man page, you will see that H (0x48) and BS (0x08) are shifted by 64. This explains some other bindings other bindings `^M` -> return and `^I` -> tab, `^J` -> newline, `^[` -> escape, but might also be the reason for things like `^G` -> bell).