Can I navigate zsh's tab-completion menu with vi-like hjkl keys?
Yes, you can by enabling menu select
:
zstyle ':completion:*' menu select
zmodload zsh/complist
...
# use the vi navigation keys in menu completion
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
The closest I've come to this is using CTRL-N and CTRL-P to move forward and backward through the list of possible completions, instead of Tab and Shift-Tab. This is more vi
-like navigation.
In a config .zsh
file I achieve this with:
bindkey '^n' expand-or-complete
bindkey '^p' reverse-menu-complete
And relatedly:
bindkey '^k' up-history
bindkey '^j' down-history
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward
Here are the docs for the bindings.