Sunday, July 10, 2011

Re: arrow keys don't move cursor but output ABCD in INSERT mode

On Mon, 4 Jul 2011, Kent wrote:

>
>  hi guys,
> last weekend I finally did the switch from .vim to vim-addon-manager.
> after the change, I made some small tests, almost everything looks
> fine. but the arrow key don't move cursor in INsert mode any longer,
> just ouput A, B, C, and D. I remembered that could be the
> vi-compatible problem. So I added 
>
> set nocp 
>
> in my .vimrc. unfortunately, this didn't help.  I open a file, try :set cp ? ,
> "nocompatible" was returned.
>
> In gvim, arrow keys work fine, the problem happens only with vim in terminal.
>
> Do you guys have any idea, where is the problem? please give me a
> hint, thank you!

I'm not sure why it would be related to switching from .vim to VAM, but
this might be a problem with your system's terminfo/termcap libraries.
Maybe the way you've set up VAM no longer sources some systemwide vimrc.

Often distributions work around problems with the arrow keys in
particular by hardcoding sequences into /etc/vimrc (or similar). E.g.
on OpenSUSE, the systemwide startup file has:

if &term =~ "xterm"
let myterm = "xterm"

" ... later in that file ...

if myterm == "xterm" || myterm == "kvt" || myterm == "gnome"
" ...
map <Esc>[A <Up>
map <Esc>[B <Down>
map <Esc>[C <Right>
map <Esc>[D <Left>

So, it's working around a deficiency (which might not even still be
present) of the terminfo files that didn't list the "application mode"
(also called "keypad transmit mode") sequences for the arrow keys.

I don't see any such workarounds in arch's startup file
/usr/share/vim/vimfiles/archlinux.vim (sourced by /etc/vimrc). But I
still think that's the rough outline of where the problem lies.

The reason it works in gvim is that it doesn't use an extra translation
layer that's necessary in (terminal-)vim. It can directly read the keys
that are sent to it. Terminal vim only gets what it can decode.

One way to determine where the problem might occur would be to grep for
OA, OB, OC, OD in some of your own startup files. (Maybe you have
something from long ago that worked around this issue, and the switch
from .vim to VAM bypasses that workaround?)

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: