zsh-vi-mode icon indicating copy to clipboard operation
zsh-vi-mode copied to clipboard

Use vi-mode with history-search?

Open knauth opened this issue 1 year ago • 3 comments

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

  1. Enable plugin
  2. Type in the prompt
  3. Press ctrl+p, up, or j in normal mode

Expected behavior

history-search is executed as in the normal input mode.

knauth avatar Sep 28 '23 18:09 knauth

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")

Fred-Sheppard avatar Oct 17 '23 23:10 Fred-Sheppard

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")

mbpowers avatar Nov 26 '23 12:11 mbpowers

I got it working in normal mode with zvm_after_init_commands, however is it possible to achieve this in insert mode?

jagjordi avatar May 02 '24 11:05 jagjordi