zsh-users
 help / color / mirror / code / Atom feed
* wanted: viins-mode and digit argument with a,i,A and such
@ 2000-07-17 12:26 Matthias Kopfermann
  2000-07-17 13:02 ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Matthias Kopfermann @ 2000-07-17 12:26 UTC (permalink / raw)
  To: zsh-users

hi all!

when i use bindkey -e, i can insert one character 10 times with
ESC 10 <character>.

With vi one normally uses something like 10i<character>.
This is not possible with ZSH ( bindkey -v set ).
One real advantage of bindkey -e here.
Has someone thought about inventing something like it?

(BTW: the bash cannot do it, too. nor can tcsh.)
Until now i just switch to EMACS-mode but of course it would be
something, if this usual vi-behavior was possible.

Matthias


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

* Re: wanted: viins-mode and digit argument with a,i,A and such
  2000-07-17 12:26 wanted: viins-mode and digit argument with a,i,A and such Matthias Kopfermann
@ 2000-07-17 13:02 ` Peter Stephenson
  2000-07-17 17:04   ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2000-07-17 13:02 UTC (permalink / raw)
  To: Zsh users list

> hi all!
> 
> when i use bindkey -e, i can insert one character 10 times with
> ESC 10 <character>.
> 
> With vi one normally uses something like 10i<character>.
> This is not possible with ZSH ( bindkey -v set ).
> One real advantage of bindkey -e here.
> Has someone thought about inventing something like it?

If you are using 3.1, try a widget like

read-and-insert-char () {
  local char i bound
  read -k char
  # Use padding trickery to add character multiple times.
  # Expands to something like ${(l.10..j.):-}
  # which means pad to ten characters using the fill character j, but
  # with no parameter, so we end up with pure padding.
  if [[ $char = . ]]; then bound=:; else bound=.; fi
  eval LBUFFER="\"\${LBUFFER}\${(l.${NUMERIC:-1}.${bound}$char${bound}):-}\""
}
zle -N read-and-insert-char
bindkey -M vicmd '^xi' read-and-insert-char

Go to vi command mode, type a number, the key sequence bound to the widget,
then a character, and it will be inserted that many times.

If you want to insert a longer string that many times, you will need to
expand the `read -k char' to a loop which reads a lot of characters until
you get an escape.  (It would be nice to have a minibuffer read for this
sort of thing.)  Then you will need to turn the bit which adds to LBUFFER
into a proper loop --- straightforward, I just couldn't be bothered to do
it the long-winded way.

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* Re: wanted: viins-mode and digit argument with a,i,A and such
  2000-07-17 13:02 ` Peter Stephenson
@ 2000-07-17 17:04   ` Bart Schaefer
  2000-07-17 17:33     ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2000-07-17 17:04 UTC (permalink / raw)
  To: Peter Stephenson, Zsh users list

On Jul 17,  2:02pm, Peter Stephenson wrote:
} Subject: Re: wanted: viins-mode and digit argument with a,i,A and such
}
} > hi all!
} > 
} > when i use bindkey -e, i can insert one character 10 times with
} > ESC 10 <character>.
} > 
} > With vi one normally uses something like 10i<character>.
} > This is not possible with ZSH ( bindkey -v set ).
} 
} If you are using 3.1, try a widget like [...]

I generally agree with the new philosophy of not adding things as builtins
that can be done as widgets, but this is so unbelievably trivial and so
completely general that I have no idea why we shouldn't do it:

Index: Src/Zle/zle_vi.c
===================================================================
@@ -82,6 +82,8 @@
 	vichgbufptr = 1;
 	vichgrepeat = 0;
     }
+    if (zmod.flags & MOD_MULT)
+	prefixflag = 1;
 }
 
 /**/

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: wanted: viins-mode and digit argument with a,i,A and such
  2000-07-17 17:04   ` Bart Schaefer
@ 2000-07-17 17:33     ` Peter Stephenson
  2000-07-17 18:13       ` Bart Schaefer
  2000-07-17 20:14       ` Thomas Köhler
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Stephenson @ 2000-07-17 17:33 UTC (permalink / raw)
  To: Zsh users list

> } > when i use bindkey -e, i can insert one character 10 times with
> } > ESC 10 <character>.
> } > 
> } > With vi one normally uses something like 10i<character>.
> } > This is not possible with ZSH ( bindkey -v set ).
> } 
> } If you are using 3.1, try a widget like [...]
> 
> I generally agree with the new philosophy of not adding things as builtins
> that can be done as widgets, but this is so unbelievably trivial and so
> completely general that I have no idea why we shouldn't do it:

This isn't quite how vi handles it, however.  It would wait till you hit
escape, then insert everything you typed that many times.  That would need
more work.  Plus in zsh there are other ways of exiting insert mode than
returning to command mode --- what should happen on `return'?

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* Re: wanted: viins-mode and digit argument with a,i,A and such
  2000-07-17 17:33     ` Peter Stephenson
@ 2000-07-17 18:13       ` Bart Schaefer
  2000-07-17 20:14       ` Thomas Köhler
  1 sibling, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-07-17 18:13 UTC (permalink / raw)
  To: Peter Stephenson, Zsh users list

On Jul 17,  6:33pm, Peter Stephenson wrote:
} Subject: Re: wanted: viins-mode and digit argument with a,i,A and such
}
} > } > when i use bindkey -e, i can insert one character 10 times with
} > } > ESC 10 <character>.
} > } > 
} > } > With vi one normally uses something like 10i<character>.
} > } > This is not possible with ZSH ( bindkey -v set ).
} > } 
} > } If you are using 3.1, try a widget like [...]
} > 
} > I generally agree with the new philosophy of not adding things as builtins
} > that can be done as widgets, but this is so unbelievably trivial and so
} > completely general that I have no idea why we shouldn't do it:
} 
} This isn't quite how vi handles it, however.

True, but it is how your read-and-insert-char widget handles it.

} It would wait till you hit escape, then insert everything you typed
} that many times. That would need more work.

Yes; I have a vague idea that it could be done by stashing away a copy
of the zmod structure, and then upon ESC you restore it, decrement the
zmult field, and invoke virepeatchange() ... the tricky bit could be
interaction with the `lastmod' copy of zmod that startvichange() uses.
Or maybe lastmod already contains almost everything we need ...

} Plus in zsh there are other ways of exiting insert mode than
} returning to command mode --- what should happen on `return'?

The same thing that happens now when you type e.g. `8 d RET' -- it just
accepts the buffer as it stands, aborting the repeat.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: wanted: viins-mode and digit argument with a,i,A and such
  2000-07-17 17:33     ` Peter Stephenson
  2000-07-17 18:13       ` Bart Schaefer
@ 2000-07-17 20:14       ` Thomas Köhler
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas Köhler @ 2000-07-17 20:14 UTC (permalink / raw)
  To: Zsh users list

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

On Mon, Jul 17, 2000 at 07:34:43PM +0200,
Peter Stephenson <pws@cambridgesiliconradio.com> wrote:
> 
> > } > when i use bindkey -e, i can insert one character 10 times with
> > } > ESC 10 <character>.
> > } > 
> > } > With vi one normally uses something like 10i<character>.
> > } > This is not possible with ZSH ( bindkey -v set ).
> > } 
> > } If you are using 3.1, try a widget like [...]
> > 
> > I generally agree with the new philosophy of not adding things as builtins
> > that can be done as widgets, but this is so unbelievably trivial and so
> > completely general that I have no idea why we shouldn't do it:
> 
> This isn't quite how vi handles it, however.  It would wait till you hit
> escape, then insert everything you typed that many times.  That would need
> more work.  Plus in zsh there are other ways of exiting insert mode than
> returning to command mode --- what should happen on `return'?

the usual thing, plus the characters last inserted being the new
$LBUFFER  - hey, this would be cool (:-)

CU,
Thomas

-- 
 Thomas Köhler Email:   jean-luc@picard.franken.de     | LCARS - Linux
     <><        WWW:     http://jeanluc-picard.de      | for Computers
                IRC:             jeanluc               | on All Real
               PGP public key available from Homepage! | Starships

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

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

* Re: wanted: viins-mode and digit argument with a,i,A and such
  2000-07-17 13:39 ` Matthias Kopfermann
@ 2000-07-17 14:06   ` Peter Stephenson
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2000-07-17 14:06 UTC (permalink / raw)
  To: Zsh users list

> On Mon, Jul 17, 2000 at 02:02:21PM +0100, Peter Stephenson wrote:
> > I just couldn't be bothered to do
> > it the long-winded way.
> Yes, that is why i stopped doing it.

If it can be done in a widget, it probably should be.  The function
interface in 3.1 is now powerful enough that you need a very good reason
for adding something to the basic shell.  We can easily add new zle widget
functions to the distribution which are essentially indistinguishable from
hard-coded functions but don't add to the shell and can be modified.  One
day they may be made more easily configurable along the lines of the new
completion system.

By the way, I said you couldn't do a minibuffer read, but using `zle -R
string...' you can make it look as if you can.

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* Re: wanted: viins-mode and digit argument with a,i,A and such
       [not found] <no.id>
@ 2000-07-17 13:39 ` Matthias Kopfermann
  2000-07-17 14:06   ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Matthias Kopfermann @ 2000-07-17 13:39 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh users list

On Mon, Jul 17, 2000 at 02:02:21PM +0100, Peter Stephenson wrote:
> I just couldn't be bothered to do
> it the long-winded way.
Yes, that is why i stopped doing it. It is not that important, on
the other hand this really is typical vi-behavior, so it would be
cool, if it was with the standard ZSH.
"Look here, ZSH alone does it right, bash and tcsh can't " :)

Matthias


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

end of thread, other threads:[~2000-07-17 20:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-17 12:26 wanted: viins-mode and digit argument with a,i,A and such Matthias Kopfermann
2000-07-17 13:02 ` Peter Stephenson
2000-07-17 17:04   ` Bart Schaefer
2000-07-17 17:33     ` Peter Stephenson
2000-07-17 18:13       ` Bart Schaefer
2000-07-17 20:14       ` Thomas Köhler
     [not found] <no.id>
2000-07-17 13:39 ` Matthias Kopfermann
2000-07-17 14:06   ` Peter Stephenson

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