how to understand bindkey

Comming from this page with information on how to customize zsh I encounter this

# oh wow!  This is killer...  try it!
bindkey -M vicmd "q" push-line

I’m not able to find a man page for bindkey, nor understanding what is the key being binded, what does -M means and what is vicmd.

So I’ve no idea how to know whats the beautifier killer feature 🙂

Asked By: Arnold Roa

||
% type bindkey
bindkey is a shell builtin

So its documentation is in the zsh manual, not in a man page of its own. Although there’s a man zshbuiltins, the bindkey builtin is not documented there because it’s part of a semi-autonomous piece of zsh, the line editor zle, and so it’s documented in man zshzle.

You can find the documentation by running run-help bindkey in zsh, or pressing M-h while the cursor is on a bindkey command. This requires run-help to be properly set up, which for some reason is not the case by default: it’s an alias to man. To get a useful run-help, put these lines in your .zshrc:

unalias run-help 2>/dev/null
autoload -U run-help

Alternatively, use man zshall. Or if you’re browsing a hypertext version of the manual, use the functions index, which also lists builtins.


vicmd is the keymap used in vi command mode. push-line is an editor widget, which have their own index. So this command makes q “pause” the current line in vi command mode (for some reason this feature, which is indeed useful, is only bound to a key by default in emacs mode).

Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.