I'm in the process of migrating from helm to ivy/counsel, and I would like to replicate a binding that I had in my previous setup.

When browsing the results minibuffer (for example in counsel-M-x), I would like to have the help for the current result displayed when pressing TAB. To get help currently I need to do M-o h. Since this is an ivy action, I'm not sure how to add a key binding to just TAB.

2 Answers 2


I've found the solution, (intern (ivy-state-current ivy-last)) will return the symbol of the current ivy result, which I can then pass to describe-function or describe-variable.

(defun counsel-describe-function-or-variable ()
  "Display help about the currently selected ivy result.
Assumes the symbol is a function and tries with a variable describe-function fails."
  (let ((inhibit-message t)
        (current-symbol (intern (ivy-state-current ivy-last))))
    (condition-case nil
        (describe-function current-symbol)
       (describe-variable current-symbol)))))

(define-key counsel-describe-map (kbd "TAB") 'counsel-describe-function-or-variable)

I didn't find a way to properly distinguish between counsel-describe-variable and the rest of the describe commands, so I catch the error and try describe-variable when describe-function fails.


I have adapted your answer and extend it to toggle Help window (helpful when we want it gone from the screen without leaving the minibuffer) and perform Ivy's native TAB (albeit with one more key stroke).

(defun my-ivy-toggle-help/tab (&rest _args)
  "Either describe current symbol or perform partial complete.
If last command is `self' and \"*Help*\" window is shown, delete it; else describe current symbol.
Ivy's native 2nd <TAB> is performed at the 3rd one."
  (let ((help-window (get-buffer-window "*Help*"))
        (symbol (intern (ivy-state-current ivy-last))))
    (if (equal last-command 'my-ivy-toggle-help/tab)
     (if help-window
        (with-selected-window help-window
    (describe-symbol symbol))))

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.