4

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

4

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:

(minibuffer-with-setup-hook
    #'evil-ex-setup
  (setq result
        (read-from-minibuffer
         ":"
         (or initial-input
             (and evil-ex-previous-command
                  (format "(default: %s) " evil-ex-previous-command)))
         evil-ex-completion-map
         nil
         'evil-ex-history
         evil-ex-previous-command
         t)))

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))
1
  • 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 that you have read and understand our privacy policy and code of conduct.

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