Reputation: 569
I'm using the zsh
shell on my Ubuntu 20.04 and I'm starting to learn how to use vim
as well.
Having oh-my-zsh
installed, I actually use the vi-mode
plugin in order to use vim with zsh.
It works well and it's very handy.
However, before using zsh's vi-mode, I was used to the arrow keys.
There is this widget called history-beginning-search-forward
in zsh (not sure if this is the correct one though).
When I type the beginning of my command, I could use the arrow keys in order to go back through my history that started with the same command.
This widget doesn't work with vi-mode. When I'm in normal mode, the j
and k
keys use the classic history search feature (going to the last command and then back to the previous ones regardless of the command I already typed in).
I would like to know if it's possible to create a custom bindkey for vim's normal mode and to use this widget with my j
and k
keys.
And eventually bind the classic search mode to other keys such as Ctrl+j
and Ctrl+k
for example.
Upvotes: 2
Views: 1155
Reputation: 7020
Add this to your .zshrc
file:
bindkey -M vicmd "j" up-line-or-beginning-search
bindkey -M vicmd "k" down-line-or-beginning-search
Upvotes: 4