Vim via ssh (putty)

Vim via ssh (putty)

Post by Matt M » Fri, 20 Jun 2003 05:39:07



Hi all. Any Vim gurus out there? Just one simple question. I am logging
in to my freeBSD 4.8 box via ssh through the putty client for windows.
My login shell is bash. When I fire up Vim, the arrow keys don't work in
insert mode. They just print "A", "B", "C", or "D" followed by a new
line. This only happens with putty. If I use the openssh client, the
arrow keys work for navigation but only after dropping me back into
command mode. What I would like is for the keys to work as expeted (move
the cursor around) while staying in insert mode, which is a feature of
Vim I believe. I know it has something to do with the terminal type
being advertised by the client and the keymappings, but I don't know
what. I have set my terminal type to xterm in putty, which is what the
$TERM variable is, but no go. Can anyone give me a hint here?

Thanks in advance.

Matt M.

 
 
 

Vim via ssh (putty)

Post by Michel Tal » Fri, 20 Jun 2003 22:37:25



> Hi all. Any Vim gurus out there? Just one simple question. I am logging
> in to my freeBSD 4.8 box via ssh through the putty client for windows.
> My login shell is bash. When I fire up Vim, the arrow keys don't work in
> insert mode. They just print "A", "B", "C", or "D" followed by a new
> line. This only happens with putty. If I use the openssh client, the
> arrow keys work for navigation but only after dropping me back into
> command mode. What I would like is for the keys to work as expeted (move
> the cursor around) while staying in insert mode, which is a feature of
> Vim I believe. I know it has something to do with the terminal type
> being advertised by the client and the keymappings, but I don't know
> what. I have set my terminal type to xterm in putty, which is what the
> $TERM variable is, but no go. Can anyone give me a hint here?

> Thanks in advance.

For me putty and vim coexist reasonably well, i don't have this problem.
The only problem i have is that CTL-V doesn't mork for pasting, i have
to use Shift-Insert. Check your .vimrc on the distant machine, double
check that TERM is indeed xterm as set by the distant machine.

> Matt M.


--

Michel TALON

 
 
 

Vim via ssh (putty)

Post by Matt » Sat, 21 Jun 2003 01:49:24




> > Hi all. Any Vim gurus out there? Just one simple question. I am logging
> > in to my freeBSD 4.8 box via ssh through the putty client for windows.
> > My login shell is bash. When I fire up Vim, the arrow keys don't work in
> > insert mode. They just print "A", "B", "C", or "D" followed by a new
> > line. This only happens with putty. If I use the openssh client, the
> > arrow keys work for navigation but only after dropping me back into
> > command mode. What I would like is for the keys to work as expeted (move
> > the cursor around) while staying in insert mode, which is a feature of
> > Vim I believe. I know it has something to do with the terminal type
> > being advertised by the client and the keymappings, but I don't know
> > what. I have set my terminal type to xterm in putty, which is what the
> > $TERM variable is, but no go. Can anyone give me a hint here?

> > Thanks in advance.

> For me putty and vim coexist reasonably well, i don't have this problem.

I have fixed the problem by turning off the compatible option -
":set nocompatible". Actually, I aliased vim to "vim -N". I haven't yet
figured out how to get just the arrow keys working without having to
turn this off. This still doesn't explain the printing of "A", "B",
etc. while using putty, but I guess I can live with it for now.

Quote:> The only problem i have is that CTL-V doesn't mork for pasting, i have
> to use Shift-Insert.

Yea, Shift-Insert works, so does right clicking.

Quote:> Check your .vimrc on the distant machine, double

Don't have one.

Quote:> check that TERM is indeed xterm as set by the distant machine.

It is.

Quote:

> Michel TALON

--

Matt M.

 
 
 

Vim via ssh (putty)

Post by Kirk Job-Slude » Sat, 21 Jun 2003 02:51:17


Digging around on this it seems to be a "feature" of compatible mode.
The only thing I can figure is that either putty or vim is dropping you
into compatible mode by default.  Having a .vim file sets default mode
to nocompatible.  My putty configuration seems to send escaped keypad
and function keys by default.  You can change this on the
Terminal->Keyboard to see if that helps.


> I have fixed the problem by turning off the compatible option -
> ":set nocompatible". Actually, I aliased vim to "vim -N". I haven't yet
> figured out how to get just the arrow keys working without having to
> turn this off. This still doesn't explain the printing of "A", "B",
> etc. while using putty, but I guess I can live with it for now.

--
Kirk
http://www.jobsluder.net/~kirk/
"Power corrupts, powerpoint corrupts absolutely." --Vinton Cerf
 
 
 

Vim via ssh (putty)

Post by Christopher Benson-Manic » Sat, 21 Jun 2003 03:26:20


Kirk Job-Sluder$ cat /dev/random

Quote:> Having a .vim file sets default mode

That would be .vimrc, right?

--
Christopher Benson-Manica          | Jumonji giri, for honour.
E-mail at ataru(at)*space.org  |

 
 
 

Vim via ssh (putty)

Post by Michel Tal » Sat, 21 Jun 2003 18:01:59



>> For me putty and vim coexist reasonably well, i don't have this problem.

> I have fixed the problem by turning off the compatible option -
> ":set nocompatible". Actually, I aliased vim to "vim -N". I haven't yet
> figured out how to get just the arrow keys working without having to
> turn this off. This still doesn't explain the printing of "A", "B",
> etc. while using putty, but I guess I can live with it for now.

Funny, i don't have that in my .vimrc, it must happen as a consequence
of other options. In fact i have:
syntax on
set showcmd
set visualbell
set backspace=2
set ruler
set mouse=nvi
set cb=autoselect
set textwidth=78
set nowrap  
" set cindent for C files
au  FileType  c  set cindent
set shiftwidth=2
set viminfo='10,\"50
set laststatus=0
set complete=.,b,t,k
set dictionary=/usr/share/dict/web2
if has("cscope")
                set csprg=/usr/local/bin/cscope
                set csto=0
                set cst
                set nocsverb
                cs add cscope.out
                set csverb
endif

Quote:

>> The only problem i have is that CTL-V doesn't mork for pasting, i have
>> to use Shift-Insert.

> Yea, Shift-Insert works, so does right clicking.

Right clicking doesn't work for me, only shift-insert succeeds in
pasting, strange isn't it?

Quote:>> Check your .vimrc on the distant machine, double

> Don't have one.

>> check that TERM is indeed xterm as set by the distant machine.

> It is.

>> Michel TALON

--

Michel TALON

 
 
 

Vim via ssh (putty)

Post by Kirk Job-Slude » Sun, 22 Jun 2003 03:01:35




>>>For me putty and vim coexist reasonably well, i don't have this problem.

>>I have fixed the problem by turning off the compatible option -
>>":set nocompatible". Actually, I aliased vim to "vim -N". I haven't yet
>>figured out how to get just the arrow keys working without having to
>>turn this off. This still doesn't explain the printing of "A", "B",
>>etc. while using putty, but I guess I can live with it for now.

> Funny, i don't have that in my .vimrc, it must happen as a consequence
> of other options.

Just read this in the Vim book last night.  (I'm one of those weird
luddites that prefer a paper manual.)  Vim defaults to compatible mode
unless there is a user .vimrc  .  If there is a .vimrc, vim starts in
noncompatible mode.  Searching around on google, it appears that
noncompatible mode includes cursor keybindings for more terminals than
compatible mode.

So what I think is happening is that since Matt did not have a .vimrc,
vim defaulted to compatible mode which does not understand some cursor
keybindings.  (I can repeat this behavior with putty on my system.)

--
Kirk
http://www.jobsluder.net/~kirk/
"Power corrupts, powerpoint corrupts absolutely." --Vinton Cerf

 
 
 

Vim via ssh (putty)

Post by Matt M » Sun, 22 Jun 2003 17:52:33




[...]

>> Funny, i don't have that in my .vimrc, it must happen as a consequence
>> of other options.

> Just read this in the Vim book last night.  (I'm one of those weird
> luddites that prefer a paper manual.)  Vim defaults to compatible mode
> unless there is a user .vimrc  .  If there is a .vimrc, vim starts in
> noncompatible mode.  Searching around on google, it appears that
> noncompatible mode includes cursor keybindings for more terminals than
> compatible mode.

> So what I think is happening is that since Matt did not have a .vimrc,
> vim defaulted to compatible mode which does not understand some cursor
> keybindings.  (I can repeat this behavior with putty on my system.)

This is true. A simple `touch .vimrc' does the trick to get rid of
compatible mode by default. That fixes the arrow keys problem. Now I am
having the same behavior with the 10-keypad. I have tried a number of
different settings in putty for the keyboard. With the function keys and
keypad set to Linux, I can get the keypad to work everywhere but in vim.
Vim just prints out "w", "y", ".", etc.

--
Matt M.

 
 
 

Vim via ssh (putty)

Post by Rudi Ahler » Mon, 23 Jun 2003 01:00:14


My putty works very well, expect for the fact that the home key simply
prints a ~ on my screen, it doesn't go home. If I set the TERM=linux, then
it goes to the beginning of the line. But TERM=linux doesn't work well on
the console itself. Then I have to use TERM=cons25 again. Is there a way to
fix this?

--

Kind Regards
Rudi Ahlers

Compassion is difficult to give away because it keeps coming back.



> [...]

> >> Funny, i don't have that in my .vimrc, it must happen as a consequence
> >> of other options.

> > Just read this in the Vim book last night.  (I'm one of those weird
> > luddites that prefer a paper manual.)  Vim defaults to compatible mode
> > unless there is a user .vimrc  .  If there is a .vimrc, vim starts in
> > noncompatible mode.  Searching around on google, it appears that
> > noncompatible mode includes cursor keybindings for more terminals than
> > compatible mode.

> > So what I think is happening is that since Matt did not have a .vimrc,
> > vim defaulted to compatible mode which does not understand some cursor
> > keybindings.  (I can repeat this behavior with putty on my system.)

> This is true. A simple `touch .vimrc' does the trick to get rid of
> compatible mode by default. That fixes the arrow keys problem. Now I am
> having the same behavior with the 10-keypad. I have tried a number of
> different settings in putty for the keyboard. With the function keys and
> keypad set to Linux, I can get the keypad to work everywhere but in vim.
> Vim just prints out "w", "y", ".", etc.

> --
> Matt M.


 
 
 

Vim via ssh (putty)

Post by Brian K. Whit » Mon, 23 Jun 2003 12:56:02



> My putty works very well, expect for the fact that the home key simply
> prints a ~ on my screen, it doesn't go home. If I set the TERM=linux, then
> it goes to the beginning of the line. But TERM=linux doesn't work well on
> the console itself. Then I have to use TERM=cons25 again. Is there a way
> to fix this?

> --

> Kind Regards
> Rudi Ahlers

> Compassion is difficult to give away because it keeps coming back. "Matt




>> [...]

>> >> Funny, i don't have that in my .vimrc, it must happen as a
>> >> consequence of other options.

>> > Just read this in the Vim book last night.  (I'm one of those weird
>> > luddites that prefer a paper manual.)  Vim defaults to compatible mode
>> > unless there is a user .vimrc  .  If there is a .vimrc, vim starts in
>> > noncompatible mode.  Searching around on google, it appears that
>> > noncompatible mode includes cursor keybindings for more terminals than
>> > compatible mode.

>> > So what I think is happening is that since Matt did not have a .vimrc,
>> > vim defaulted to compatible mode which does not understand some cursor
>> > keybindings.  (I can repeat this behavior with putty on my system.)

>> This is true. A simple `touch .vimrc' does the trick to get rid of
>> compatible mode by default. That fixes the arrow keys problem. Now I am
>> having the same behavior with the 10-keypad. I have tried a number of
>> different settings in putty for the keyboard. With the function keys and
>> keypad set to Linux, I can get the keypad to work everywhere but in vim.
>> Vim just prints out "w", "y", ".", etc.

>> --
>> Matt M.


The default emulation in putty is neither "cons25" nor "linux" but "xterm"
You can set TERM=xterm, or xterm-color.

Or, putty supports two other emulations that work quite well in freebsd.

In putty you can choose keyboard type "SCO" and set TERM=cons25

or you can choose keyboard type "Linux" and set TERM=linux.

--

+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx  Linux SCO  Prosper/FACTS AutoCAD  #callahans Satriani

 
 
 

Vim via ssh (putty)

Post by Matt M » Mon, 23 Jun 2003 16:16:12


[...]

Quote:> In putty you can choose keyboard type "SCO" and set TERM=cons25

> or you can choose keyboard type "Linux" and set TERM=linux.

Thanks Brian. I could swear I tried both of these combos. I think my
problem was that I had the "Initial state of cursor keys" set to
"Application" when I tried them.

You made my day.

--
Matt M.