Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vi mode cursor position



Christopher Paul wrote:
> Salutations Zsh Users,
>
> I just started using zsh. It's always fun to learn a new trick. I am a long-time vi-mode user. One thing that's different from ksh and bash is the cursor position after an ESC-k. With zsh, the cursor is positioned on the last character of the last command after an ESC-k. With ksh and bash, the cursor is positioned at the first character of the last command after an ESC-k.
>
> I'm pretty sure there is a way to change this in zsh. Can anyone give me a pointer?

By default, k is bound to up-line-or-history.
There are alternatives that differ in terms of the cursor position. For
example:

  bindkey -a k history-beginning-search-backward

However that may break other things like moving the cursor in a
multi-line buffer so you may want to use a custom widget that does
something like:

  if [[ $LBUFFER == *$'\n'* ]]; then
    zle .up-line
  else
    zle .history-beginning-search-backward
  fi

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author