zsh-vi-mode: Conflicts with zsh-autosuggestions setting

I’m using oh-my-zsh to manage plugins. With zsh-vi-mode enabled, this zsh-autosuggestions setting:

bindkey '^ ' autosuggest-accept 

is not working, specifically I cannot use ctrl-space to complete autosuggestions. I can only use the default right-arrow key to complete.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@jeffreytse The snippet works! Thank you very much!

@g6ai, could you try the below snippet:

# Put it to the `.zshrc` file
function zvm_after_init() {
  zvm_bindkey viins '^@' autosuggest-accept
}
❯ bindkey -M viins | grep accept
"^J" accept-line
"^M" accept-line

Hi @g6ai , also, you run the command bindkey -M viins | grep accept and provide the content to me.

❯ git log | head
commit d354b6d85e1d82f5a9f5246ff99aa78b86fc5c22
Author: jeffreytse <jeffreytse.mail@gmail.com>
Date:   Mon Mar 15 19:13:27 2021 +0800

    fix: binding ctrl-<space> does not work (#57)

    This commit fixed the issue that `ctrl-<space>`, that is the control
    character `^@` could not be escaped to a printable character.
❯ git rev-parse HEAD
d354b6d85e1d82f5a9f5246ff99aa78b86fc5c22

Thank you very much. I searched around and used this way to verify if this is a problem on my terminal, by using this key-binding in .zshrc:

bindkey '^@' self-insert

And when I type ctrl-<space>, ^@ is printed in the terminal. So it should not be a problem on the terminal.

I’ve tried disabling all my custom setting, only leaving basic oh-my-zsh lines and two plugins:

### start of oh-my-zsh ###
export ZSH="$HOME/.oh-my-zsh"

plugins=(zsh-autosuggestions zsh-vi-mode)

source $ZSH/oh-my-zsh.sh

# Put plugins config after this line
# zsh-autosuggestions
bindkey '^ ' autosuggest-accept

# zsh-vi-mode
ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BEAM
ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BLOCK
### end of oh-my-zsh ###

still not solved. More info on my setup:

OS: macOS 10.14.6 (for 32-bit compatibility reason I have to stay at this version) Terminal: I tried both Terminal.app and iTerm2.app, same results

Please let me know if I can provide any further info, thanks!