From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15671 invoked from network); 9 May 2000 11:02:28 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 May 2000 11:02:28 -0000 Received: (qmail 18049 invoked by alias); 9 May 2000 11:01:36 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3059 Received: (qmail 18012 invoked from network); 9 May 2000 11:01:34 -0000 From: "Bart Schaefer" Message-Id: <1000509110032.ZM18045@candle.brasslantern.com> Date: Tue, 9 May 2000 11:00:32 +0000 In-Reply-To: <0FUA009H4DMVBA@la-la.cambridgesiliconradio.com> Comments: In reply to Peter Stephenson "Re: use vim to vi" (May 9, 10:42am) References: <0FUA009H4DMVBA@la-la.cambridgesiliconradio.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Raju K V , zsh-users@sunsite.auc.dk Subject: Re: use vim to vi MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 9, 10:42am, Peter Stephenson wrote: } Subject: Re: use vim to vi } } > also in vi mode, how can I open the command line in vi (like 'v' command in } > ksh)? } } - The traditional zsh way of doing this (needed for 3.0.x) would involve } pushing the current input somewhere, then running a command which uses } what's there. Where is `somewhere', buffer stack or history? Should be the buffer stack. } [...] if I use the buffer stack it's hard to get a command to read it. Eh? You must mean, hard to get an external command to read it? The difficult part in 3.0 is keeping the vi command itself out of the history. You need to setopt hist_ignore_space. ------------ setopt hist_ignore_space function vihist() { local tmp=${TMPPREFIX}${$}hist read -Erz >| $tmp vi $tmp print -Rz - "$(<$tmp)" } bindkey -v bindkey -a '\M-q' push-input # replaces push-line in 3.0.x bindkey -a -s v '\M-qi vihist\n' ------------ The push-line bindings in the vi cmd map have gone away in 3.1, along with a number of other non-vi-ish bindings. BTW, if I do the "bindkey -a ..." without first "bindkey -v" the new key bindings go ... somewhere ... but seemingly not into the vi cmd map (in 3.0.x, I still mean). Is the command map reinitialized at "bindkey -v" time or something? } - In 3.1.x you might hope you could run `fc -e vi' in an editing widget. } This doesn't seem to work. I don't think the history is set up right. Yup, there's nothing in the history for the current line until after the accept-line is executed. I tried playing with hend()/hbegin() inside of the `print -s' implementation but got nowhere. } - Next attempt is to use the contents of $BUFFER (which certainly does work } and is a better way of doing it in zsh), dump it to a file and run vi on } that. vi is doing something very strange. I get "vim: input is not a terminal" or something like that when I run it from inside an editor widget. That's fairly bizarre; what has ZLE done with standard input? The snippet above works fine, though. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com