I think this is a duplicate, but I can't flag it while it has a bounty.Update:
The usualSince you're using a Hydra, I think the best way to create a keybinding that applies in all buffers and doesn't get shadowed by bindings of any other modesdo this is to create your owna minor mode, and putthen define the keybinding therehydra in that minor-mode.
Here's the duplicate that answers this, from @kaushalmodi:Start by creating your minor mode as described in this answer.
You can installThen you just need to define the use-package package available from Melpa and make use of bind-key* or bind-keys* macro that's part ofhydra in the bindmode-key packagemap for that ships with use-package.
From the documentation of bind-key.elmode:
;; If you want the keybinding to override all minor modes that may also bind
;; the same key, use the `bind-key*' form:
;;
;; (bind-key* "<C-return>" 'other-window)
;; To bind multiple keys in a `bind-key*' way (to be sure that your bindings
;; will not be overridden by other modes), you may use `bind-keys*' macro:
;;
;; (bind-keys*
;; ("C-o" . other-window)
;; ("C-M-n" . forward-page)
;; ("C-M-p" . backward-page))
(defhydra python-indent (my-mode-map "C-c")
"Adjust python indentation."
(">" python-indent-shift-right "right")
("<" python-indent-shift-left "left"))
Original Source. See also other answers at that link for alternatives Once you've run all this code, you can turn on my-mode
, and you should have access to your keybinding in all buffers.