I use zsh's menu-based tab completion. I press Tab once, and a list of possible completions appears. If I press Tab again, I can navigate this list with the arrow keys. However, is it possible to navigate them with the
vi-like H, J, K, L keys instead?
Yes, you can by enabling
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
In a config
.zsh file I achieve this with:
bindkey '^n' expand-or-complete bindkey '^p' reverse-menu-complete
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.