is it possible to define key bindings at one place in an init file? something like:

    '(("C-x M-f" 'fly)
      ("C-x M-k" 'run)

2 Answers 2


If you are open to installing a package, give use-package (also available on Melpa) a try, which comes with the bind-key.el library.

With use-package installed, you can do something like below:

  :map MINOR-MODE-MAP ; if this line is removed, bindings happen in `global-map'
                      ; else they happen in MINOR-MODE-MAP
  ("C-x M-f" . fly)
  ("C-x M-k" . run))

There are more variants of bind-keys like bind-key, bind-keys*, bind-key* and even unbind-key. Check out the documentation in the header of bind-key.el to learn more.

The added benefit of using bind-keys (and family) is that you can see a summary of all your personal keybindings currently in effect using M-x describe-personal-keybindings. That will also tell you if you've overridden a pre-bound key using bind-keys (and family).


Yes, of course.

(defun define-key-bindings (bindings &optional keymap)
  (unless keymap (setq keymap  global-map))
  (dolist (bdg  bindings)
    (define-key keymap (kbd (car bdg)) (cadr bdg))))

(define-key-bindings '(("C-x M-f" fly) ("C-x M-k" run)))

(Drop the quote marks before the command names - not needed.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.