I am trying to bind CTRL-B to perform the Evil command :buffers. The reason I am doing this is because I want to scroll through the open buffers with j and k and then press <RET> to make the selection.

What I tried was adding the following code to my configuration file:

;; Switch Evil-mode buffers
(define-key evil-normal-state-map (kbd "C-B") ":buffers")

The result of reloading this configuration (:eval-buffer) and then pressing CTRL-B leads to:

After 0 kbd macro iterations: Can't find "

How can we bind to an Ex-mode command?

  • By the way: there's probably a typo you need to fix: there is no evil-mode-map. Do you mean evil-normal-state-map or something along those lines?
    – Dan
    Apr 1, 2016 at 23:38
  • Dan that's right. Thanks. :) I wanted to bind to every mode. Apr 2, 2016 at 13:48

1 Answer 1


From the evil source, we can see:

(evil-ex-define-cmd "buffers" 'buffer-menu)

In this case, I'd recommend binding to the command directly, instead of going through the ex interface.

(define-key evil-normal-state-map (kbd "C-B") #'buffer-menu)

However, if you find that you absolutely must, you can use a keyboard macro:

(define-key evil-normal-state-map (kbd "C-B") (kbd ":buffers"))
  • 1
    Just a note: you don't actually need to consult the source to find the functions for ex commands: there is an evil-ex-commands alist. eg. (cdr (assoc "buffers" evil-ex-commands)) will return the function corresponding to ":buffers".
    – pyrocrasty
    Sep 11, 2017 at 11:58

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.