6

As an example, when I use M-x save-buffer Emacs says in the minibuffer:

 You can run the command ‘save-buffer’ with C-x C-s

I'm using Swiper/Ivy; I want to know if there is a way to instruct Ivy to append the keybinding of a command while it shows the completion options; something like save-buffer (C-x C-s).

Basil
  • 12,019
  • 43
  • 69
Anderson Torres
  • 250
  • 2
  • 8

1 Answers1

12

The command counsel-M-x does this for you:

Screenshot of <code>counsel-M-x</code> in action

(ivy) Global key bindings recommends you remap M-x (execute-extended-command) to counsel-M-x in order to avail of its increased Ivy-ness, e.g. via

(when (commandp 'counsel-M-x)
  (global-set-key [remap execute-extended-command] #'counsel-M-x))

Alternatively (and more simply), you can just enable counsel-mode and have it automatically remap various built-in commands, including describe-function and describe-variable, to their fancier counsel counterparts.

Update

In fact, vanilla Emacs 28 has this functionality too:

Emacs 28 M-x screenshot

Basil
  • 12,019
  • 43
  • 69