zsh-workers
 help / color / mirror / code / Atom feed
* end-of-line not working as advertised?
@ 2015-08-20 19:36 Robin Lee Powell
  2015-08-21  0:48 ` Vincent Lefevre
  2015-08-21  1:25 ` Bart Schaefer
  0 siblings, 2 replies; 8+ messages in thread
From: Robin Lee Powell @ 2015-08-20 19:36 UTC (permalink / raw)
  To: zsh-workers


Please cc: me as I'm not on the list.

beginning-of-line works, in that repeated presses take me to
successive line beginnings.  end-of-line, not so much.  See video: 

https://www.youtube.com/watch?v=A5ZX3H48i5s

The man page bits:

  end-of-line (^E) (unbound) (unbound)
   Move to the end of the line.  If already at the end of the line, move to the end of the next line, if any.


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

* Re: end-of-line not working as advertised?
  2015-08-20 19:36 end-of-line not working as advertised? Robin Lee Powell
@ 2015-08-21  0:48 ` Vincent Lefevre
  2015-08-21  1:25 ` Bart Schaefer
  1 sibling, 0 replies; 8+ messages in thread
From: Vincent Lefevre @ 2015-08-21  0:48 UTC (permalink / raw)
  To: Robin Lee Powell; +Cc: zsh-workers

On 2015-08-20 12:36:01 -0700, Robin Lee Powell wrote:
> Please cc: me as I'm not on the list.
> 
> beginning-of-line works, in that repeated presses take me to
> successive line beginnings.  end-of-line, not so much.  See video: 
> 
> https://www.youtube.com/watch?v=A5ZX3H48i5s
> 
> The man page bits:
> 
>   end-of-line (^E) (unbound) (unbound)
>    Move to the end of the line.  If already at the end of the line, move to the end of the next line, if any.

For me, it works. And I didn't know this feature...
I've tried on:

for i in 1
do
echo $i
done

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


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

* Re: end-of-line not working as advertised?
  2015-08-20 19:36 end-of-line not working as advertised? Robin Lee Powell
  2015-08-21  0:48 ` Vincent Lefevre
@ 2015-08-21  1:25 ` Bart Schaefer
  2015-08-21  5:29   ` Robin Lee Powell
  1 sibling, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2015-08-21  1:25 UTC (permalink / raw)
  To: Robin Lee Powell, zsh-workers

On Aug 20, 12:36pm, Robin Lee Powell wrote:
} 
} Please cc: me as I'm not on the list.
} 
} beginning-of-line works, in that repeated presses take me to
} successive line beginnings.  end-of-line, not so much.  See video:

You're using an emacs-mode key binding in vicmd mode.  In vicmd mode,
the position of the cursor isn't allowed to move beyond the last
real character on any line, so end-of-line never actually reaches
(what it defines as) the end of the current line, and therefore never
advances to the next line.

If you try it in either actual emacs mode, or in viins mode where you
have also defined it, it works as documented.

Nothing is guaranteed to work exactly as documented if you mix the
widgets from different modes; vicmd mode is especially unlike either
of the others.

-- 
Barton E. Schaefer


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

* Re: end-of-line not working as advertised?
  2015-08-21  1:25 ` Bart Schaefer
@ 2015-08-21  5:29   ` Robin Lee Powell
  2015-08-21  6:39     ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Robin Lee Powell @ 2015-08-21  5:29 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On Thu, Aug 20, 2015 at 06:25:12PM -0700, Bart Schaefer wrote:
> On Aug 20, 12:36pm, Robin Lee Powell wrote: } 
> } Please cc: me as I'm not on the list.
> } 
> } beginning-of-line works, in that repeated presses take me to
> } successive line beginnings.  end-of-line, not so much.  See video:
> 
> You're using an emacs-mode key binding in vicmd mode.  In vicmd
> mode, the position of the cursor isn't allowed to move beyond the
> last real character on any line, so end-of-line never actually
> reaches (what it defines as) the end of the current line, and
> therefore never advances to the next line.
> 
> If you try it in either actual emacs mode, or in viins mode where
> you have also defined it, it works as documented.
> 
> Nothing is guaranteed to work exactly as documented if you mix the
> widgets from different modes; vicmd mode is especially unlike
> either of the others.

OK, fair enough.

What I actually *wanted*, btw, was a way to get to the beginning or
end of a multi-line command; these were just the best versions I
saw.

-- 
http://intelligence.org/ :  Our last, best hope for a fantastic future.
.i ko na cpedu lo nu stidi vau loi jbopre .i dafsku lu na go'i li'u .e
lu go'i li'u .i ji'a go'i lu na'e go'i li'u .e lu go'i na'i li'u .e
lu no'e go'i li'u .e lu to'e go'i li'u .e lu lo mamta be do cu sofybakni li'u


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

* Re: end-of-line not working as advertised?
  2015-08-21  5:29   ` Robin Lee Powell
@ 2015-08-21  6:39     ` Bart Schaefer
  2015-08-21  7:07       ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2015-08-21  6:39 UTC (permalink / raw)
  To: zsh-workers; +Cc: Robin Lee Powell

On Aug 20, 10:29pm, Robin Lee Powell wrote:
}
} What I actually *wanted*, btw, was a way to get to the beginning or
} end of a multi-line command; these were just the best versions I
} saw.

Try end-of-buffer-or-history ... yes, it's still an emacs-mode widget,
but because it deals with history as well as buffers it handles vicmd
a little better.


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

* Re: end-of-line not working as advertised?
  2015-08-21  6:39     ` Bart Schaefer
@ 2015-08-21  7:07       ` Bart Schaefer
  2015-08-22  5:14         ` Robin Lee Powell
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2015-08-21  7:07 UTC (permalink / raw)
  To: zsh-workers; +Cc: Robin Lee Powell

On Aug 20, 11:39pm, Bart Schaefer wrote:
}
} Try end-of-buffer-or-history ... yes, it's still an emacs-mode widget,

Or try this:

vi-next-end-of-line() {
  local curs=$CURSOR
  zle vi-end-of-line
  if (( curs <= CURSOR )); then
    NUMERIC=2 zle vi-end-of-line
  fi
}
zle -N vi-next-end-of-line
bindkey -a ^E vi-next-end-of-line


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

* Re: end-of-line not working as advertised?
  2015-08-21  7:07       ` Bart Schaefer
@ 2015-08-22  5:14         ` Robin Lee Powell
  2015-08-22 20:16           ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Robin Lee Powell @ 2015-08-22  5:14 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On Fri, Aug 21, 2015 at 12:07:39AM -0700, Bart Schaefer wrote:
> On Aug 20, 11:39pm, Bart Schaefer wrote:
> }
> } Try end-of-buffer-or-history ... yes, it's still an emacs-mode widget,
> 
> Or try this:
> 
> vi-next-end-of-line() {
>   local curs=$CURSOR
>   zle vi-end-of-line
>   if (( curs <= CURSOR )); then
>     NUMERIC=2 zle vi-end-of-line
>   fi
> }
> zle -N vi-next-end-of-line
> bindkey -a ^E vi-next-end-of-line

That is *SUPER* helpful!  Thank you so much.


-- 
http://intelligence.org/ :  Our last, best hope for a fantastic future.
.i ko na cpedu lo nu stidi vau loi jbopre .i dafsku lu na go'i li'u .e
lu go'i li'u .i ji'a go'i lu na'e go'i li'u .e lu go'i na'i li'u .e
lu no'e go'i li'u .e lu to'e go'i li'u .e lu lo mamta be do cu sofybakni li'u


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

* Re: end-of-line not working as advertised?
  2015-08-22  5:14         ` Robin Lee Powell
@ 2015-08-22 20:16           ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2015-08-22 20:16 UTC (permalink / raw)
  To: zsh-workers; +Cc: Robin Lee Powell

On Aug 21, 10:14pm, Robin Lee Powell wrote:
}
} That is *SUPER* helpful!  Thank you so much.

This is actually a better way, I think:

vi-next-end-of-line() {
  # In vicmd mode, CURSOR can never be at EOL, and in fact can't
  # be closer than 2 positions to the left of EOL, because the
  # on-screen visible cursor is always one place to the right of
  # the value of CURSOR and never "over" the newline itself.
  if [[ $KEYMAP = vicmd ]]; then
    (( CURSOR++ ))
  fi
  if [[ $BUFFER[CURSOR+1] = $'\n' ]]; then
    NUMERIC=2
  fi
  zle vi-end-of-line	
}


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

end of thread, other threads:[~2015-08-22 20:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-20 19:36 end-of-line not working as advertised? Robin Lee Powell
2015-08-21  0:48 ` Vincent Lefevre
2015-08-21  1:25 ` Bart Schaefer
2015-08-21  5:29   ` Robin Lee Powell
2015-08-21  6:39     ` Bart Schaefer
2015-08-21  7:07       ` Bart Schaefer
2015-08-22  5:14         ` Robin Lee Powell
2015-08-22 20:16           ` Bart Schaefer

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).