zsh-users
 help / color / mirror / code / Atom feed
* VI command line editing
@ 1997-01-28  0:18 Vidiot
  1997-01-28 15:10 ` Zefram
  0 siblings, 1 reply; 13+ messages in thread
From: Vidiot @ 1997-01-28  0:18 UTC (permalink / raw)
  To: ZSH Mailing List

I've been off the list for too long of a time and recently upgraded to the
latest version of ZSH under Solaris 2.5.1.

I've run into a problem, based upon the way it used to work in zsh 2.5+ and
the current zsh 3.+

It has to do with command line editing.  If bindkey -v is set in my .zshrc,
command line editing does not work the same as before.  Previously pressing
the up or down arrow would retrieve the previous command and I would have
simple editing by using the left/right arrow keys/backspace, etc. in order
to edit a line.  If I want vi editing at that point, I could press the ESC
key to get into vi edit mode.

BUT, pressing the up or down key causes a problem, since the escape sequence
is used to place me in vi edit mode and the rest of the cursor key sequence
causes screen flashing (vi editng error).

If I turn off bindkey, then the simple editing works as before, but now
vi editing cannot be brought into play.

What happened?  Why did this change and what do I need to do to have simple
editing, i.e., the escape character of the up/down cursor key is ignored,
unless the ESCAPE key is pressed without any characters following it?

Is there some timing value I have to set?

I can find nothing in the documentation that makes me believe that things
should be operating differently.

Thanks for any tips or pointers.

MB
-- 
System Administrator - Finnigan FT/MS - Madison WI. <URL:http://www.ftms.com/>
e-mail: brown@ftms.com
phone: (608) 273-8262 ext: 612  fax: (608) 273-8719
Visit - <URL:http://www.cdsnet.net/vidiot/>  (Your link to Star Trek and UPN)


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

* Re: VI command line editing
  1997-01-28  0:18 VI command line editing Vidiot
@ 1997-01-28 15:10 ` Zefram
  1997-01-28 16:27   ` Bart Schaefer
  0 siblings, 1 reply; 13+ messages in thread
From: Zefram @ 1997-01-28 15:10 UTC (permalink / raw)
  To: Vidiot; +Cc: zsh-users

Vidiot wrote:
>BUT, pressing the up or down key causes a problem, since the escape sequence
>is used to place me in vi edit mode and the rest of the cursor key sequence
>causes screen flashing (vi editng error).

It's a change in the handling of multi-character key bindings.
Previously there was just one multi-character key binding table for vi
mode, used in both insert and command modes -- this was a kludge that
only really worked for the built-in key bindings.  In 3.1 there is a
new key binding system, that properly separates command and insert
modes, so the arrow keys are now (for vi compatibility) bound only in
command mode.  It's easy to bind them in insert mode yourself.

-zefram


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

* Re: VI command line editing
  1997-01-28 15:10 ` Zefram
@ 1997-01-28 16:27   ` Bart Schaefer
  1997-01-28 16:31     ` Zefram
  0 siblings, 1 reply; 13+ messages in thread
From: Bart Schaefer @ 1997-01-28 16:27 UTC (permalink / raw)
  To: Zefram, zsh-users

On Jan 28,  3:10pm, Zefram wrote:
} Subject: Re: VI command line editing
}
} It's a change in the handling of multi-character key bindings.
} [...] the arrow keys are now (for vi compatibility) bound only in
} command mode.  It's easy to bind them in insert mode yourself.

Maybe the old vt100 arrow bindings should appear in StartupFiles/zshrc
with a comment explaining the change?

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* Re: VI command line editing
  1997-01-28 16:27   ` Bart Schaefer
@ 1997-01-28 16:31     ` Zefram
  0 siblings, 0 replies; 13+ messages in thread
From: Zefram @ 1997-01-28 16:31 UTC (permalink / raw)
  To: schaefer; +Cc: zefram, zsh-users

Bart Schaefer wrote:
>Maybe the old vt100 arrow bindings should appear in StartupFiles/zshrc
>with a comment explaining the change?

That would probably be a good idea.

-zefram


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

* Re: vi command line editing
  1998-03-24 19:38             ` Andrew Main
@ 1998-03-24 20:30               ` Thomas Koehler
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Koehler @ 1998-03-24 20:30 UTC (permalink / raw)
  To: zsh-users

On Tue, Mar 24, 1998 at 07:38:27PM +0000, Andrew Main wrote:

> Thomas Koehler wrote:
> >> The versions of vi that I've seen map arrow keys in insert
> >> mode to "^[ka" and so on,
> >
> >Then you haven't seen vim yet (:-)
> 
> Ah, but vim is not vi.  Not by a long way.

Right - but when you said "versions of vi", I thought of vi-clones :)

> >> which of course doesn't work with repeat counts.
> >
> >How should it work with repeat counts anyways? If you enter a number in
> >input mode, it is inserted as text...
> 
> I meant a repeat count on the insert command.

Well, now it gets clear - right, repeated inserts don't work when moving
around with the cursor keys - even not with vim.

I don't know whether or not this should be considered a problem - cursor
keys aren't intended to be used in insertmode anyways ;-)

> -zefram

CU,
Thomas

-- 
    Thomas Köhler    Email:     jean-luc@picard.franken.de
        <><           WWW:    http://home.pages.de/~jeanluc/
                      IRC:               jeanluc
      LCARS --- Linux for Computers on All Real Starships


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

* Re: vi command line editing
  1998-03-24 18:57           ` Thomas Koehler
@ 1998-03-24 19:38             ` Andrew Main
  1998-03-24 20:30               ` Thomas Koehler
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Main @ 1998-03-24 19:38 UTC (permalink / raw)
  To: Thomas Koehler; +Cc: zsh-users

Thomas Koehler wrote:
>> The versions of vi that I've seen map arrow keys in insert
>> mode to "^[ka" and so on,
>
>Then you haven't seen vim yet (:-)

Ah, but vim is not vi.  Not by a long way.

>> which of course doesn't work with repeat counts.
>
>How should it work with repeat counts anyways? If you enter a number in
>input mode, it is inserted as text...

I meant a repeat count on the insert command.

-zefram


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

* Re: vi command line editing
  1998-03-24 18:35         ` Andrew Main
@ 1998-03-24 18:57           ` Thomas Koehler
  1998-03-24 19:38             ` Andrew Main
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Koehler @ 1998-03-24 18:57 UTC (permalink / raw)
  To: zsh-users

On Tue, Mar 24, 1998 at 06:35:32PM +0000, Andrew Main wrote:

> The versions of vi that I've seen map arrow keys in insert
> mode to "^[ka" and so on,

Then you haven't seen vim yet (:-)

> which of course doesn't work with repeat counts.

How should it work with repeat counts anyways? If you enter a number in
input mode, it is inserted as text...

(anyways, in vim, you can hit ^O<count>[hjkl] for movements - in
general, you can use ^O<commandmode-command> in insertmode in vim, and
you are back in insertmode afterwards)

> -zefram

CU,
Thomas [always vimming]

-- 
    Thomas Köhler    Email:     jean-luc@picard.franken.de
        <><           WWW:    http://home.pages.de/~jeanluc/
                      IRC:               jeanluc
      LCARS --- Linux for Computers on All Real Starships


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

* Re: vi command line editing
  1998-03-24 18:04       ` Stephen Marley
@ 1998-03-24 18:35         ` Andrew Main
  1998-03-24 18:57           ` Thomas Koehler
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Main @ 1998-03-24 18:35 UTC (permalink / raw)
  To: Stephen Marley; +Cc: zsh-users

Stephen Marley wrote:
>Why are you being so pedantic?  Should I have said `input' rather than
>`insert'?  Why is it then that if I do :se showmode it says `insert'?
>What's wrong with saying movement doesn't `work'?
>
>What terminology could I have used that wouldn't have irked you? 

Sorry, I didn't mean it to be taken as a complaint.  While there can
be said to be an insert mode, it is an input-reading mode, not really
comparable to the command mode.  Movement *can't* work in insert mode,
because the insert mode is merely where a long command argument is
being read.  The versions of vi that I've seen map arrow keys in insert
mode to "^[ka" and so on, which of course doesn't work with repeat counts.

-zefram


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

* Re: vi command line editing
  1998-03-24 17:06     ` Andrew Main
@ 1998-03-24 18:04       ` Stephen Marley
  1998-03-24 18:35         ` Andrew Main
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Marley @ 1998-03-24 18:04 UTC (permalink / raw)
  To: zsh-users

Quoting Andrew Main (zefram@tao.co.uk):
> Stephen Marley wrote:
> >You see, my fingers are tuned to using the older vi's (eg SunOS's) where
> >movement using the arrow keys doesn't work in insert mode.
> 
> Arrow keys don't properly `work' in insert mode in *any* vi, since there
> is no such thing as an insert `mode'.

Why are you being so pedantic?  Should I have said `input' rather than
`insert'?  Why is it then that if I do :se showmode it says `insert'?
What's wrong with saying movement doesn't `work'?

What terminology could I have used that wouldn't have irked you? 

Anyway, there is such a thing as an insert `mode', I have the sources
from Bill Joy and Mark Horton's ex version 3 and there are plenty of
references to insert mode (it's a terminal attribute) and the Vim
sources use this term in exactly the way I do. So there! (sticks out
tongue).

Thanks for the help anyway.

-- 
stephen@memex.com


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

* Re: vi command line editing
  1998-03-24 16:26   ` Stephen Marley
@ 1998-03-24 17:06     ` Andrew Main
  1998-03-24 18:04       ` Stephen Marley
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Main @ 1998-03-24 17:06 UTC (permalink / raw)
  To: Stephen Marley; +Cc: zsh-users

Stephen Marley wrote:
>You see, my fingers are tuned to using the older vi's (eg SunOS's) where
>movement using the arrow keys doesn't work in insert mode.

Arrow keys don't properly `work' in insert mode in *any* vi, since there
is no such thing as an insert `mode'.

>        I have always map!ed the arrow keys to <esc>l or <esc>k etc so
>that they take me into command mode and then move. 

You can do much the same thing with zsh:

bindkey -s "^[[A" "^[k"
bindkey -s "^[[B" "^[j"
bindkey -s "^[[C" "^[l"
bindkey -s "^[[D" "^[h"

bindkey -s acts like vi's map command.  The recent betas can do this
in a slightly better way, but I think this is exactly the functionality
you're looking for.

-zefram


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

* Re: vi command line editing
  1998-03-24 15:46 ` Andrew Main
@ 1998-03-24 16:26   ` Stephen Marley
  1998-03-24 17:06     ` Andrew Main
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Marley @ 1998-03-24 16:26 UTC (permalink / raw)
  To: zsh-users

Quoting Andrew Main (zefram@tao.co.uk):
> Stephen Marley wrote:
> >How can I get vi command line editing to start in command mode rather
> >than insert mode after moving in the history with the arrow keys?  I am
> >using 3.0.5. 
> 
> Use the arrow keys while in command mode.

I really want to avoid having to remember to type <ESC> before issuing
some vi commands. This causes me enormous grief after years of using zsh
as I'm never sure which mode I'm in so I find myself typing 'B' or 'cw'
or 'i' when I'm in already in insert mode. It does my head in!

You see, my fingers are tuned to using the older vi's (eg SunOS's) where
movement using the arrow keys doesn't work in insert mode. To stop
spurious A's and D's (from the arrow keys escape sequences) appearing in
my text I have always map!ed the arrow keys to <esc>l or <esc>k etc so
that they take me into command mode and then move. 

Even now that I use Vim 5 I still keep these mappings because I am so
used to being in command mode after moving with the arrow keys however
there seems to be no way to make zsh behave like this.

My current bindings for the arrow keys are:

"^[[A"  history-search-backward
"^[[B"  history-search-forward
"^[[C"  forward-char
"^[[D"  backward-char

So I what I would really like, for example, is that my first typed up
arrow takes me into command mode and then does history-search-backward
regardless of my current mode. Is there any way to achieve this?

-- 
stephen@memex.com


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

* Re: vi command line editing
  1998-03-24 15:14 vi " Stephen Marley
@ 1998-03-24 15:46 ` Andrew Main
  1998-03-24 16:26   ` Stephen Marley
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Main @ 1998-03-24 15:46 UTC (permalink / raw)
  To: Stephen Marley; +Cc: zsh-users

Stephen Marley wrote:
>How can I get vi command line editing to start in command mode rather
>than insert mode after moving in the history with the arrow keys?  I am
>using 3.0.5. 

Use the arrow keys while in command mode.

-zefram


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

* vi command line editing
@ 1998-03-24 15:14 Stephen Marley
  1998-03-24 15:46 ` Andrew Main
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Marley @ 1998-03-24 15:14 UTC (permalink / raw)
  To: zsh-users

How can I get vi command line editing to start in command mode rather
than insert mode after moving in the history with the arrow keys?  I am
using 3.0.5. 

-- 
stephen@memex.com


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

end of thread, other threads:[~1998-03-24 20:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-28  0:18 VI command line editing Vidiot
1997-01-28 15:10 ` Zefram
1997-01-28 16:27   ` Bart Schaefer
1997-01-28 16:31     ` Zefram
1998-03-24 15:14 vi " Stephen Marley
1998-03-24 15:46 ` Andrew Main
1998-03-24 16:26   ` Stephen Marley
1998-03-24 17:06     ` Andrew Main
1998-03-24 18:04       ` Stephen Marley
1998-03-24 18:35         ` Andrew Main
1998-03-24 18:57           ` Thomas Koehler
1998-03-24 19:38             ` Andrew Main
1998-03-24 20:30               ` Thomas Koehler

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