jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
2.99k stars 103 forks source link

History search not working as before/intended #148

Open yuannan opened 2 years ago

yuannan commented 2 years ago

General information

Basic examination

Problem description

Searching using arrow keys no longer works. The binds from "bindkey" do not differ for "^[[A" and "^[[B" which confuses me.

As per: https://github.com/jeffreytse/zsh-vi-mode/issues/12 I tried

zvm_after_init_commands+=("bindkey '^[[A' up-line-or-search" "bindkey '^[[B' down-line-or-search")

This works for the command key word but not the entire command. For example using vi-mode:

ping 1.1

*up*

ping 1.1.1.1

This searches for "^ping 1.1[.*]" and completes the command as well as the string after wards. Working as intended.

However while using zsh-vi-mode:

ping 1.1

*up*

ping 9.9.9.9

This searches for "^ping[.*]". It does search for ping but for all pings. Removing functionality that was once had.

I have read the README.md and know about { /, n, N} to search and then navigate back and forwards. This gets back some functionality but not all as this instead searches for "[.*]ping 1.1[.*]" which is all history containing the string "ping 1.1".

I just want to search like I was doing before. This should be easily avoided by the code first checking for binds and then ignoring them if it detects previous binds instead of just assuming the user wants to use zsh-vi-mode binds.

This all works completely normally and expected with "vi-mode" plugin that this is supposedly better and should replace. Until this is fixed I cannot say this is better or improved. Just different.

JettChenT commented 2 years ago

I had the same issue, and It doesn't look like that this is currently possible with zsh-vi-mode.

Here's a useful post I found on the internet that accomplishes this without the plugin, all you have to do is paste the code snippet in the post into your .zshrc

45mg commented 1 year ago

This works for the command key word but not the entire command.

@yuannan I know it's been 2 years, but for this specific behavior, you need zvm_after_init_commands+=("bindkey '^[[A' up-line-or-beginning-search" "bindkey '^[[B' down-line-or-beginning-search")