[comp.unix.questions] Using a vt220 clone with unix vi?

pln@egret1.stanford.edu (Patrick L. Nolan) (03/07/91)

I have a colleague who has recently started using a Sun computer
by means of a VT220 clone terminal.  This terminal has problems
dealing with vi because the ESC key doesn't send the ESC character
in VT220 mode.  Instead it sends a four-character escape sequence
that confuses vi mightily.

I would like to know if there's a way to change termcap or tset or teach
vi to deal with this sequence as if it was ESC.  Or maybe to make
the terminal send ESC, without giving up the rest of the VT220
keyboard mapping.

I have already thought of a couple of workarounds, neither of which 
is quite satisfactory:

 1. Set the terminal to VT100 mode.  This works, but he also uses
 a Vax.  The keyboard layout is much better for VMS in VT220 mode.
 Switching between the two modes is annoying.

 2. Use emacs instead of vi.  Neither of us really knows emacs,
 and it looks like it would be hard to learn.  Besides, doesn't
 emacs use ESC too?

-- 
*   Patrick L. Nolan            (415)723-0133                 *
*   W. W. Hansen Experimental Physics Laboratory (HEPL)       * 
*   Stanford University                                       *
*   Bitnet: PLN@SLACVM    Internet: pln@egret1.stanford.edu   *
--
*   Patrick L. Nolan            (415)723-0133                 *
*   W. W. Hansen Experimental Physics Laboratory (HEPL)       * 
*   Stanford University                                       *
*   Bitnet: PLN@SLACVM    Internet: pln@egret1.stanford.edu   *

frechett@spot.Colorado.EDU (-=Runaway Daemon=-) (03/07/91)

In article <pln.668280591@egret1> pln@egret1.stanford.edu (Patrick L. Nolan) writes:
>I would like to know if there's a way to change termcap or tset or teach
>vi to deal with this sequence as if it was ESC.  Or maybe to make
>the terminal send ESC, without giving up the rest of the VT220
>keyboard mapping.

Why not make vi recognize the difference.  Here is an example while in vi:
Type this sequence.
:map! abc <control-V><control-[>      ^[ is <ESC>.
So you will see
:map! abc ^[ When you are done.
What happens is that any time you type abc, it will send ESC to vi.  This is an
easy thing to put in your .exrc file or just to type in.  I suspect that the
sequence that pressing the ESC key sends is odd enough that you are not going
to just stumble on it some day while typing.  

	ian

--
Ian Frechette             UNIXOPS   University of Colorado at Boulder.

frank@urz.unibas.ch (03/07/91)

In article <pln.668280591@egret1>, pln@egret1.stanford.edu (Patrick L. Nolan) writes:
> 
> I have a colleague who has recently started using a Sun computer
> by means of a VT220 clone terminal.  This terminal has problems
> dealing with vi because the ESC key doesn't send the ESC character
> in VT220 mode.  Instead it sends a four-character escape sequence
> that confuses vi mightily.
> 
On a real vt220 you can use CTRL-3 or CTRL-[ as an alternative to the missing
ESC key. Most clones also have an alternative, especially the CTRL-[, which
is the ASCII control sequence of ESC. Hope this helps.
-Robert

Robert Frank, Institut for Informatics, University of Basel, Switzerland
frank@urz.unibas.ch

ian@unipalm.uucp (Ian Phillipps) (03/08/91)

pln@egret1.stanford.edu (Patrick L. Nolan) writes:

>I have a colleague who has recently started using a Sun computer
>by means of a VT220 clone terminal.  This terminal has problems
>dealing with vi because the ESC key doesn't send the ESC character
>in VT220 mode.  Instead it sends a four-character escape sequence
>that confuses vi mightily.

>I would like to know if there's a way to change termcap or tset or teach
>vi to deal with this sequence as if it was ESC.  Or maybe to make
>the terminal send ESC, without giving up the rest of the VT220
>keyboard mapping.

Yes.
Use the "map": do "map <whatever string it is> <escape>"
and dont forget "map! <...> <...>"

OK, it's a bootstrap problem, but you can get ESC by CTRL/[ anyhow.
You'll need some number of ^Vs to protect the ESC key (one if you type the
map in at the vi prompt, more to enter them into a .exrc file).


Ian
---
Look! no jokes in the .signature!!

cepek@vixvax.mgi.com (03/09/91)

In article <1991Mar7.012051.27038@csn.org>, frechett@spot.Colorado.EDU (-=Runaway Daemon=-) writes:
> In article <pln.668280591@egret1> pln@egret1.stanford.edu (Patrick L. Nolan) writes:
>>I would like to know if there's a way to change termcap or tset or teach
>>vi to deal with this sequence as if it was ESC.  Or maybe to make
>>the terminal send ESC, without giving up the rest of the VT220
>>keyboard mapping.
> 
> Why not make vi recognize the difference.  Here is an example while in vi:
> Type this sequence.
> :map! abc <control-V><control-[>      ^[ is <ESC>.
> So you will see
> :map! abc ^[ When you are done.
> What happens is that any time you type abc, it will send ESC to vi.  This is an
> easy thing to put in your .exrc file or just to type in.  I suspect that the
> sequence that pressing the ESC key sends is odd enough that you are not going
> to just stumble on it some day while typing.  

Taking this one step further, why not choose as your "unique sequence" the
characters that the "VT220" puts out when you press the ESC key?  It likely
puts out  <esc> [ 2 3 ~  (five characters) instead of the <esc> character
you want.  I know nothing about vi, but wouldn't that do the trick?

+----------------------------------+-----------------------------+ - - - - - -
|  Mike Cepek, Programmer/Analyst  |  Internet: CEPEK@MGI.COM    |
|  Management Graphics, Inc.       |     Voice: +1 612/851-6112  |  "Engage."
|  1401 East 79th Street           |  Operator: +1 612/854-1220  |
|  Minneapolis, MN  55425  USA     |       Fax: +1 612/854-6913  |
+----------------------------------+-----------------------------+ - - - - - -

bhoughto@pima.intel.com (Blair P. Houghton) (03/10/91)

In article <1991Mar8.171343.825@vixvax.mgi.com> cepek@vixvax.mgi.com writes:
>Taking this one step further, why not choose as your "unique sequence" the
>characters that the "VT220" puts out when you press the ESC key?  It likely
>puts out  <esc> [ 2 3 ~  (five characters) instead of the <esc> character
>you want.  I know nothing about vi, but wouldn't that do the trick?

Which brings up that on the VT220 the ESC key can send just
the ^[, but only when you set it up in VT100 mode.

I do

	map [23~ mz

in my .exrc.  This means that the ^[ gets taken as the escape,
then vi marks my current position as point z.  I never actually
do 'z or `z, but it's a convenient NOP.

				--Blair
				  "ZZ"