(un)bind key's for beginners (or the good Emacs way) reddit / emacs ---------------------------------------------------------------------- wWA5RnA4n2P3w2WvfHq · 2022-04-06 14:17 - `kill-buffer` is bind to `C-x k` - 'kill-buffer-and-window` is bind to `C-x 4 0` I am quit new to Emacs 27. Searching around how to modify key bindings gives me a lot of possible solutions. The question is not how to do it but how to do it the right emacs way. - `kill-buffer` should be unbind - 'kill-buffer-and-window` should bind to `C-x k` And what does happen if someone tries to "override" a key-binding (before unbinding it) or when using one keybinding for two different functions? Do I need to take care of this or does Emacs this for me? What I tried so far is ```Lisp (global-unset-key (kbd "C-x k")) (global-set-key (kbd "C-x k") 'kill-buffer-and-window) ``` Seems that this works. But I am not sure if it is a good way and if this has some side effects. ---------------------------------------------------------------------- sylvain_soliman · 2022-04-06 14:34 This seems ok, but I don't think you need the `global-unset-key`. From the docs (https://www.gnu.org/software/emacs/manual/html_node/elisp/Key- Binding-Commands.html) its main use would be to avoid a _prefix_ binding issue. ---------------------------------------------------------------------- 7890yuiop · 2022-04-06 14:45 As a tangent and a primer, I highly recommend reading all of this: https://www.masteringemacs.org/article/mastering-key-bindings-emacs ---------------------------------------------------------------------- 00-11 · 2022-04-06 15:35 Ask Emacs about [Key Binding Commands](https://www.gnu.org/software/em acs/manual/html_node/elisp/Key-Binding-Commands.html). ---------------------------------------------------------------------- mwzx · 2022-04-06 17:38 This right here is the beauty of Emacs: because of its self- documenting aspect, you can ask Emacs about everything.