zsh-users
 help / color / mirror / code / Atom feed
* vi mode cursor position
@ 2019-07-11 23:52 Christopher Paul
  2019-07-13  9:24 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Paul @ 2019-07-11 23:52 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

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?

CP
--
Christopher Paul


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: vi mode cursor position
  2019-07-11 23:52 vi mode cursor position Christopher Paul
@ 2019-07-13  9:24 ` Oliver Kiddle
  2019-07-15 22:08   ` Christopher Paul
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2019-07-13  9:24 UTC (permalink / raw)
  To: Christopher Paul; +Cc: zsh-users

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: vi mode cursor position
  2019-07-13  9:24 ` Oliver Kiddle
@ 2019-07-15 22:08   ` Christopher Paul
  0 siblings, 0 replies; 3+ messages in thread
From: Christopher Paul @ 2019-07-15 22:08 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

Oliver Kiddle wrote:
 
> 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

Thanks! This seems to work for me.

> 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:

Hmm; I guess I'll know about that once I see it, but testing a multi-line buffer seems to work fine. I tested a multi-line buffer with:

echo "now is the time "\
> "for all good men"

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

I put this in my .zshrc file and it didn't seem to change anything.

Thanks again, Oliver, I really appreciate your response.

CP

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-15 22:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 23:52 vi mode cursor position Christopher Paul
2019-07-13  9:24 ` Oliver Kiddle
2019-07-15 22:08   ` Christopher Paul

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).