From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10333 invoked from network); 17 Jul 2000 13:03:15 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Jul 2000 13:03:15 -0000 Received: (qmail 14753 invoked by alias); 17 Jul 2000 13:02:49 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3289 Received: (qmail 14745 invoked from network); 17 Jul 2000 13:02:48 -0000 Date: Mon, 17 Jul 2000 14:02:21 +0100 From: Peter Stephenson Subject: Re: wanted: viins-mode and digit argument with a,i,A and such In-reply-to: "Your message of Mon, 17 Jul 2000 14:26:15 +0200." <20000717142615.A2063@linux-ws.kg-hittfeld.local> To: zsh-users@sunsite.auc.dk (Zsh users list) Message-id: <0FXU00G2VEVXZ5@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > hi all! > > when i use bindkey -e, i can insert one character 10 times with > ESC 10 . > > With vi one normally uses something like 10i. > 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 Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070