jeffreytse / zsh-vi-mode

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

Zsh history search to zvm_bindkey #286

Closed Eloquencere closed 4 months ago

Eloquencere commented 4 months ago

General information

- Terminal program: Alacritty
- Operating system: Arch Linux 6.9
- ZSH framework: zinit
- ZSH version: 5.9.0

Basic examination

Problem description

I used to use zsh's completion for command history by using the keybind - bindkey '^p' line-up-or search , and another for line down, now after switching to zvm, I know that a key can be set by doing - zvm_bindkey , so I tried that with line up search, and I am getting - line-up-or-search: function definition not found.

I even tried doing autoload -U line-up-or-search && line-up-or-search - to no avail

Reproduction steps

  1. add
    zvm_bindkey vicmd '^p' line-up-or-search 
    zvm_bindkey vicmd '^n' line-down-or-search 
    to .zshrc
  2. pressing any of the above keys(^p, ^n) in normal or insert mode doesn't do the expected completion and raises the error

Expected behavior

It's supposed to complete a command based on the previous commands that were run with that specific cli tool like cd, ls etc

noahfraiture commented 4 months ago

Hello, how did you resolve this ?

Eloquencere commented 4 months ago

it's done by adding the bindkey statement within a function called "zvm_after_init()" using "zvm_bindkey". The issue is that once vi mode is enabled in zsh, it wipes out all the keybinds configured before it, so keybinds that need to be used with the vi mode have to be registered once the setup is done

function zvm_after_init() {

Zsh-Vi-Mode

ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT
zvm_bindkey viins '^p' line-up-or-search
    zvm_bindkey viins '^n' line-down-or-search 

}

I added this line at the end of my zshrc and it's working as expected. This function is automatically called by zvm after initialisation.

noahfraiture commented 4 months ago

Ok thank you