1832084 Members
3358 Online
110037 Solutions
New Discussion

Re: arrow keys problem

 
Radhakrishnan Venkatara
Trusted Contributor

arrow keys problem

hai ,

i am facing a problem in vi editor.The arrow keys are not working in vi editor when we use windows based terminal emulators.in dos based emulators it is working fine.

i am facing this problem in two servers of Dclass type.

but in another 2 servers from the same windows emulators arrow keys are working on vi.
note:- the arrow keys is not working only on vi

waiting for ur reply

radhakrishnan
Negative thinking is a highest form of Intelligence
9 REPLIES 9
Paul R. Dittrich
Esteemed Contributor

Re: arrow keys problem

I'm going to guess that your TERM is set differently in the different logins, but....

using arrow keys in vi is very bad practice for exactly the reasons you are experiencing.

I believe your only "general-case" solution is to learn to use the H-J-K-L keys.
Volker Borowski
Honored Contributor

Re: arrow keys problem

Hello,

Windows telnet identifies as TERM "ansi" which should be reverse compatible with vt100.

May be your two boxes have no terminfo base for "ansi". I would check TERM and terminfo settings on the boxes that work and vice-versa.

HTH
Volker
Bill McNAMARA_1
Honored Contributor

Re: arrow keys problem

I believe this is configured via the stty command. I've also run into this kind of problem on other interfaces and believe in the long run using the ascii keycodes is the right way around, because the arrows are escape code sequences and terminal emulation takes an effect.

Bill
It works for me (tm)
Tracey
Trusted Contributor

Re: arrow keys problem

I guess it would all depend on the window's base emulator you are using, but I put the following commands in a file in the users home directory called .exrc - this file is pre-processed when you open vi. There is some exteranous things in it, but I wanted to give you an idea of what you can do - you will see the escape sequences for the arrows toward the bottom.

set autoindent autowrite showmatch wrapmargin=0 report=1 ic ts=4 sw=4 nows
map ^W :set wrapmargin=8
map ^X {!}sort -b
map ^[h 1G
map ^[H 1G
map ^[F G
map ^[V ^B
map ^[U ^F
map ^[T ^Yk
map ^[S ^Ej
map ^[Q i
map ^[P x
map ^[L O
map ^[M dd
map ^[K D
map ^[J DjdG$
map! ^[A ^[ka
map! ^[D ^[ha
map! ^[C ^[la
map! ^[B ^[ja
map! ^[L ^M
map! ^[Q ^[
map! ^[R ^[
Shahul
Esteemed Contributor

Re: arrow keys problem


Hi Radha

It is nice to here from U. U are lucky because in DOS mode arrow keys are working..Right? Ask those users to use DOS mode emulator. Or ask them to use H,J,K,L.
Anyway U try to find out the solution meen while.

Best of luck

Shahul
Shahul
Esteemed Contributor

Re: arrow keys problem


Hi Radha

It is nice to here from U. U are lucky because in DOS mode arrow keys are working..Right? Ask those users to use DOS mode emulator. Or ask them to use H,J,K,L.
Anyway U try to find out the solution meen while.

Idukke point onnum venda...OK...

Best of luck

Shahul
Kong Kian Chay
Regular Advisor

Re: arrow keys problem

Normally, the variable "TERM" is set to "ANSI" when you telnet from Windows. To get the keys to work correctly, you may try to set the variable "TERM" to "vt100" or "vt52". Example :

For ksh : export TERM=vt100
For csh : setenv TERM vt100

After setting the variable "TERM", issue commd "tset" to set the stty settings.

Hope this helps.
Radhakrishnan Venkatara
Trusted Contributor

Re: arrow keys problem

hai ,
thanks for ur reply. still i am facing the problem. the $TERM has been set maximumk possibiltes ttytype shows me clearly it is hp or vt100 but still i am facing problem only in vi editor. i couldn't understand what goes wrong the emulator works for one server and in another 2 it is giving the problem so i think there cannot be any problem in windows emulator.
but still only in windows emulators i am facing this problem.

hope any body will give solution

radhakrishnan
Negative thinking is a highest form of Intelligence
Bill Hassell
Honored Contributor

Re: arrow keys problem

It is important to understand that there is no ASCII code for arrow keys (or Home or End, etc). In the (really) old days, these keys were called local execution and simply moved the cursor around on the screen. This action meant nothing to vi as nothing was transmitted to the computer.

Later, terminals were enhanced to allow switching from local execution to remote transmission, typically each arrow key will transmit an escape character plus two others. vi (using the curses library) will send the command to tell the terminal to start transmitting these keycodes when the arrow keys are pressed.

PCs are not terminals although they do have a keyboard and screen. So an emulator is needed. The Windows hyperterminal has historically been a poor emulation the DEC VT100 terminal, which requires adjustment of the terminal values to make it work correctly. Also, there are several versions of the Hyperterminal (or Windows terminal emualtion).

So the key is a combination of what value has been set for $TERM and what is contained in the $HOME/.exrc file. You'll need to edit .exrc to add (or change) arrow key interpretation.


Bill Hassell, sysadmin