Skip to content

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

Open
Christian-Sidak wants to merge 1 commit into
djcopley:mainfrom
Christian-Sidak:fix/zsh-vi-mode-keybind
Open

Bind Ctrl+F in vi keymaps for zsh#92
Christian-Sidak wants to merge 1 commit into
djcopley:mainfrom
Christian-Sidak:fix/zsh-vi-mode-keybind

Conversation

@Christian-Sidak

Copy link
Copy Markdown

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

1 participant