Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vi-mode with history-search? #247

Open
3 tasks done
knauth opened this issue Sep 28, 2023 · 3 comments
Open
3 tasks done

Use vi-mode with history-search? #247

knauth opened this issue Sep 28, 2023 · 3 comments

Comments

@knauth
Copy link

knauth commented Sep 28, 2023

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 Unsupported grep -P option on Mac OS #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

  • I have read through the README page
  • I have the latest version of zsh-vi-mode
  • 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.

@Fred-Sheppard
Copy link

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

@mbpowers
Copy link

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

@jagjordi
Copy link

jagjordi commented May 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants