user2913694
user2913694

Reputation:

Why doesn't my 'jk' zsh vi-cmd-mode binding not work

I use oh-my-zsh with Zsh and I want Vim bindings on the command line. In my .zshrc, I have the following lines (full .zshrc here):

# terminal vim
bindkey -v
export KEYTIMEOUT=1
bindkey -M viins 'jk' vi-cmd-mode  # @todo - THIS DOES NOT WORK?
bindkey -M viins '^k' kill-line
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward

# show which vim mode we are in
precmd() {
  RPROMPT=""
}
zle-keymap-select() {
  RPROMPT=""
  [[ $KEYMAP = vicmd ]] && RPROMPT="(COMMAND MODE)"
  () { return $__prompt_status }
  zle reset-prompt
}
zle-line-init() {
  typeset -g __prompt_status="$?"
}
zle -N zle-keymap-select
zle -N zle-line-init

Now, I just to be able to switch back to command mode by pressing 'jk' on the command line, but it won't work. Escape does work though.

Where am I going wrong?

Upvotes: 8

Views: 3240

Answers (1)

phil pirozhkov
phil pirozhkov

Reputation: 4909

export KEYTIMEOUT=1

is the usual suspect here, it is 40 (0.4 seconds) by default. I use 10, works seamlessly with 'kj' (i prefer it inwards).

Upvotes: 16

Related Questions