jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
3.13k stars 109 forks source link

This plugin prevents abbreviations from expanding #69

Closed medwatt closed 3 years ago

medwatt commented 3 years ago

I am using this plugin to expand abbreviations.

For example:

abbr dl="cd ~/Downloads"

Typing dl followed by <space> expands dl into cd ~/Downloads. This works fine with the default vi-mode plugin from oh-my-zsh. However, when this plugin is enabled, abbreviations fail to expand.

jeffreytse commented 3 years ago

Hi @medwatt

Thanks for the reporting. I will focus on this issue and try to settle it as soon as possible. Welcome to star this project for the further updates in the future.

Thanks and regards

jeffreytse commented 3 years ago

Hi @medwatt

Actually this plugin will override the default keybindings (See here), so you should source this plugin or bind the keys after this plugin is initialized. According to the source code in zsh-abbr, here is the code snippet that you should put in your .zshrc:

# The plugin will auto execute this zvm_after_init function
function zvm_after_init() {
  # spacebar expands abbreviations
  bindkey " " _abbr_widget_expand_and_space

  # control-spacebar is a normal space
  bindkey "^ " magic-space

  # when running an incremental search,
  # spacebar behaves normally and control-space expands abbreviations
  bindkey -M isearch "^ " _abbr_widget_expand_and_space
  bindkey -M isearch " " magic-space

  # enter key expands and accepts abbreviations
  bindkey "^M" _abbr_widget_expand_and_accept
}

or easier using :

# The plugin will auto execute this zvm_after_init function
function zvm_after_init() {
  # Binding keys for zsh-abbr
  _abbr_bind_widgets
}

Thanks and regards