Skip to content

Bind Ctrl+F in vi keymaps for zsh - #92

Merged
djcopley merged 1 commit into
djcopley:mainfrom
Christian-Sidak:fix/zsh-vi-mode-keybind
Sep 13, 2026
Merged

djcopley merged 1 commit into
djcopley:mainfrom
Christian-Sidak:fix/zsh-vi-mode-keybind

Conversation

@Christian-Sidak

Copy link
Copy Markdown
Contributor

The zsh integration installs the widget with a bare bindkey '^F', which only touches whichever keymap is the current main keymap at source time. If you enable vi mode with bindkey -v after shelloracle.zsh is sourced (the usual order when the plugin line comes before the vi-mode line in .zshrc), the binding stays behind in the emacs keymap and Ctrl+F falls through to self-insert. Even with bindkey -v first, the widget was never bound in vicmd.

This binds the widget explicitly in emacs, viins, and vicmd, which is the same thing the bash integration already does with bind -m emacs-standard, bind -m vi-insert, and bind -m vi-command. It also matches how fzf handles its zsh keybindings.

Checked with zsh -f in all four orderings (emacs default, source then bindkey -v, bindkey -v then source, and bindkey -M vicmd '^F' after each), and the widget is bound in every case now. Before the change, source-then-bindkey -v left viins on self-insert and vicmd on undefined-key.

Fixes #51

The zsh integration only ran a bare bindkey, which installs the widget in
whichever keymap is active when the file is sourced. Users who enable vi
mode (bindkey -v) after sourcing ended up with Ctrl+F doing nothing, and
even when vi mode was enabled first the binding was missing from vicmd.

Bind explicitly in the emacs, viins, and vicmd keymaps, matching what the
bash integration already does with bind -m for emacs-standard, vi-insert,
and vi-command.

Fixes djcopley#51
@Christian-Sidak

Copy link
Copy Markdown
Contributor Author

Wanted to check in on this. The fix is straightforward: bindkey -v after the plugin sources means the widget only lands in the emacs keymap, so vi-mode users never see Ctrl+F work. Binding explicitly in viins and vicmd is the correct fix - I use zsh vi mode and tested it; the widget fires correctly in both insert and normal mode now. Is there anything blocking this from merging?

@djcopley

Copy link
Copy Markdown
Owner

nope, lgtm!

@djcopley
djcopley merged commit 63bfffe into djcopley:main Sep 13, 2026
8 of 9 checks passed
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

Successfully merging this pull request may close these issues.

ZSH keyboard shortcut not working in VI mode

2 participants