I understand that evil-ex-define-cmd allow me create my own ex commands.

Although in Vim, you were able to narrow down the search by doing something like

:h <term>

I'm not sure how to accomplish the same in evil, or if this is even possible.

  • I should specify: What I want to do is to take the arguments after :h and pass it into the function bound by evil-ex-define-cmd (this is currently helm). Whether that is a useful activity is best left for another discussion
    – Wagk
    Mar 26, 2017 at 7:01
  • Look at the definition of ex commands reading in extra arguments. I'll whip up a complete example later.
    – wasamasa
    Mar 26, 2017 at 7:43

1 Answer 1


An ex command is just another function. Evil defines a few extra interactive codes to retrieve what you've passed to it, <a> is the most generic one and returns the text after the command as is:

(evil-define-command my-help (arg)
  (interactive "<a>")
  (message "ARG: %s" arg))

(evil-ex-define-cmd "h[elp]" 'my-help)

:h foo will display "ARG: foo" in the echo area. Extend this as you need for whatever you're doing with Helm.

  • Thanks for the answer, though it appears that helm does not allow me to initialize searches like that
    – Wagk
    Mar 27, 2017 at 3:48

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.