Search code examples
zshzshrc

zsh vi mode Esc-k places insertion point at end of line


When I use vi command mode in bash and hit Esc+k or Ctrl+[ the cursor is placed at the beginning of the line. This is what I prefer.

When I hit hit Esc+k or Ctrl+[ in zsh, the cursor is placed at the end of the line.

How can I make the zsh vi mode act like bash vi mode?

Thanks.


Solution

  • https://unix.stackexchange.com/questions/562292/zsh-history-with-cursor-at-beginning-of-line

    For me, these lines provided the fix. Add them to .zshrc and voila.

    bindkey -v
    bindkey -a j vi-down-line-or-history
    bindkey -a k vi-up-line-or-history