For example, I have created a keybinding for Emacs mini-buffer, that will receive the [f9]-key as a confirmation (usually the RET-key).

 (define-key minibuffer-local-map (kbd "<f9>") 'exit-minibuffer)  

I use Evil mode, so would like to make a keybinding to RET in the Evil command buffer (after when you're pressing :). So that he will interpret the [f9]-key as an Enter/confirmation key.

When looking up in the documentation of Evil, I notice there are 6 state maps defined, but none of them applies on the command line, while in Vim you could map the keybindings on the command line.

Any solution on this?

1 Answer 1


That's pretty interesting. Evil does actually provide evil-ex-map, but it's for entering ex commands that are immediately executed without terminating them with RET. So I've looked a bit at the guts of evil-ex to find out why minibuffer-local-map isn't doing anything useful here:

  (setq result
         (or initial-input
             (and evil-ex-previous-command
                  (format "(default: %s) " evil-ex-previous-command)))

That third argument to read-from-minibuffer is the keymap used instead of minibuffer-local-map for tasks like terminating input. In other words, customize evil-ex-completion-map and you should be good to go:

 (eval-after-load 'evil-vars
   '(define-key evil-ex-completion-map (kbd "<f9>") 'exit-minibuffer))
  • Awesome, I learn here every time how I could it figure out myself. Thanks for your well written answer!
    – ReneFroger
    Jul 22, 2015 at 18:06

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.