zsh-users
 help / color / mirror / code / Atom feed
* use vim to vi
@ 2000-05-09  6:41 Raju K V
  2000-05-09  9:42 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Raju K V @ 2000-05-09  6:41 UTC (permalink / raw)
  To: zsh-users

hi,

When I say zsh uses vi mode for command line editing, does it actually
use the vi editor or does it have a vi emulation inbuilt? if it calls
the vi editor for command line editing, can i make it call vim instead?

also in vi mode, how can I open the command line in vi (like 'v' command in
ksh)?

Thanks in advance,
Raju
PS: please cc me in your replies.


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

* Re: use vim to vi
  2000-05-09  6:41 use vim to vi Raju K V
@ 2000-05-09  9:42 ` Peter Stephenson
  2000-05-09 11:00   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2000-05-09  9:42 UTC (permalink / raw)
  To: zsh-users, Raju K V

> When I say zsh uses vi mode for command line editing, does it actually
> use the vi editor or does it have a vi emulation inbuilt? if it calls
> the vi editor for command line editing, can i make it call vim instead?

No, it has its own built-in vi emulation.

> also in vi mode, how can I open the command line in vi (like 'v' command in
> ksh)?

I had a brief go at this (I'm not a vi mode expert) and there seem to be
all sorts of problems.  I haven't got time to investigate, so I'm hoping
this will prompt some responses.  This is unfortunately not an answer to
the original question.

- 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?  Both seem
hard: if I use the history, it's hard to get the editor to stick something
there (as we've been discovering recently), if I use the buffer stack it's
hard to get a command to read it.  What's an easy way of doing this?  It
ought to be possible to stick something in the history and just run `fc -e
vi', which will pick that up, but writing bindkey -s applets (for want of a
better word) for vi mode seems pretty hairy.

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

- 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 suspect (but haven't checked)
it's having all sorts of problems with the terminal being set up for
command line editing.

I can only hope Bart's got some answers.

-- 
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] 3+ messages in thread

* Re: use vim to vi
  2000-05-09  9:42 ` Peter Stephenson
@ 2000-05-09 11:00   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-05-09 11:00 UTC (permalink / raw)
  To: Raju K V, zsh-users

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


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

end of thread, other threads:[~2000-05-09 11:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-09  6:41 use vim to vi Raju K V
2000-05-09  9:42 ` Peter Stephenson
2000-05-09 11:00   ` 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).