zsh-vi-mode
zsh-vi-mode copied to clipboard
Use vi-mode with history-search?
General information
Please report the following information as possible as you can:
- Terminal program: Konsole (xterm-256color)
- Operating system: Linux (6.4.9-arch1-1-g14 #1 SMP PREEMPT_DYNAMIC Thu, 10 Aug 2023 05:41:11 +0000 x86_64 GNU/Linux)
- ZSH framework: oh-my-zsh master (d41ca84a)
- ZSH version: zsh 5.9 (x86_64-pc-linux-gnu)
- ZVM version: zsh-vi-mode 0.10.0
Basic examination
- [x] I have read through the README page
- [x] I have the latest version of zsh-vi-mode
- [x] I have tested with another terminal program
Problem description
Using the standard zsh keybinds, when I type in the prompt and then press the up arrow, ZSH searches history for the most recent command which begins with the text already typed in the prompt. I use this at least five times a minute when coding for speeding up repetitive tasks or finding commands. When using vi-mode the up arrow, j in normal mode, and ctrl+p all find the last executed command without taking the prompt text into account. Is there a way to enable this?
Reproduction steps
- Enable plugin
- Type in the prompt
- Press ctrl+p, up, or j in normal mode
Expected behavior
history-search is executed as in the normal input mode.
Best workaround right now is as written here.
Add this to your .zshrc
zvm_after_init_commands+=("bindkey '^[[A' up-line-or-search" "bindkey '^[[B' down-line-or-search")
If you want to use j and k instead you need to add -a to bindkey like so
zvm_after_init_commands+=("bindkey -a 'k' up-line-or-search" "bindkey -a 'j' down-line-or-search")
I got it working in normal mode with zvm_after_init_commands, however is it possible to achieve this in insert mode?