Weird cursors behaviour when using vim in terminal in insert mode

129 views
Skip to first unread message

Pablo Giménez

unread,
May 29, 2012, 1:52:26 PM5/29/12
to vim_use
Hi all.
I have an issue using vim in the termninal.
Every time I go to Indert mode and try to sue the cursor it just
begging to write the letter A,B,C,D and creates a new line.
I have been digging and seems it is because of the internal definition
of the termcap in Vim.
So I tried the next:
set term=builtin_ansi

But then it is messing up the colors.
The term is xterm-256color by default.
Is there ane way to get the cursors working properly without changing
the termn, or using the xterm terminal?
I forgot to say I am using latest vim 7.3.

Thanks



--
Un saludo
Best Regards
Pablo Giménez

Dominique Pellé

unread,
May 29, 2012, 2:26:30 PM5/29/12
to vim...@googlegroups.com
Try...

:set nocompatible

I don't remember the reason, but cursor keys only work
with nocompatible in insert mode.

-- Dominique

Pablo Giménez Pizarro

unread,
May 29, 2012, 2:34:59 PM5/29/12
to vim...@googlegroups.com


Enviado desde mi iPhone

El 29 May 2012, a las 19:26, Dominique Pellé <dominiq...@gmail.com> escribió:

> Pablo Giménez <pabl...@gmail.com> wrote:
>
>> Hi all.
>> I have an issue using vim in the termninal.
>> Every time I go to Indert mode and try to sue the cursor it just
>> begging to write the letter A,B,C,D and creates a new line.
>> I have been digging and seems it is because of the internal definition
>> of the termcap in Vim.
>> So I tried the next:
>> set term=builtin_ansi
>>
>> But then it is messing up the colors.
>> The term is xterm-256color by default.
>> Is there ane way to get the cursors working properly without changing
>> the termn, or using the xterm terminal?
>> I forgot to say I am using latest vim 7.3.
>>
>> Thanks
>
> Try...
>
> :set nocompatible
Thanks, I have already tried it.
I think it is the third line in my vimrc
>
> I don't remember the reason, but cursor keys only work
> with nocompatible in insert mode.
>
> -- Dominique
>
> --
> 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

Gary Johnson

unread,
May 29, 2012, 3:05:30 PM5/29/12
to vim_use
The value of $TERM needs to be appropriate for the terminal you are
actually using.

Vim uses $TERM to determine the terminal's capabilities and escape
sequences from your system's terminfo or termcap database. If the
value of $TERM is not correct, then Vim may obtain an incorrect
description of your arrow keys.

What is the terminal you are using and what is the value of $TERM?

Regards,
Gary

Dominique Pellé

unread,
May 29, 2012, 3:45:40 PM5/29/12
to vim...@googlegroups.com
Pablo Giménez Pizarro <pabl...@gmail.com> wrote:

> Enviado desde mi iPhone
>
> El 29 May 2012, a las 19:26, Dominique Pellé <dominiq...@gmail.com> escribió:
>
>> Pablo Giménez <pabl...@gmail.com> wrote:
>>
>>> Hi all.
>>> I have an issue using vim in the termninal.
>>> Every time I go to Indert mode and try to sue the cursor it just
>>> begging to write the letter A,B,C,D and creates a new line.
>>> I have been digging and seems it is because of the internal definition
>>> of the termcap in Vim.
>>> So I tried the next:
>>> set term=builtin_ansi
>>>
>>> But then it is messing up the colors.
>>> The term is xterm-256color by default.
>>> Is there ane way to get the cursors working properly without changing
>>> the termn, or using the xterm terminal?
>>> I forgot  to say I am using latest vim 7.3.
>>>
>>> Thanks
>>
>> Try...
>>
>>   :set nocompatible
> Thanks, I have already tried it.
> I think it is the third line in my vimrc


Then what about...

:set esckeys

I can reproduce the ABCD being inserted in insert mode
when pressing cursor keys with :set noesckeys

-- Dominique

Pablo Giménez Pizarro

unread,
May 29, 2012, 4:32:21 PM5/29/12
to vim...@googlegroups.com


Enviado desde mi iPhone
I haven't tried this.
I'll try, thanks Dominique

Pablo Giménez Pizarro

unread,
May 29, 2012, 4:59:51 PM5/29/12
to vim...@googlegroups.com


Enviado desde mi iPhone

El 29 May 2012, a las 20:05, Gary Johnson <gary...@spocom.com> escribió:
I am using gnome terminal and xterm, for both TERM is set to xterm-256color
>
> Regards,
> Gary

Gary Johnson

unread,
May 29, 2012, 5:43:59 PM5/29/12
to vim...@googlegroups.com
On 2012-05-29, Pablo Gim�nez Pizarro wrote:
> Enviado desde mi iPhone
>
> El 29 May 2012, a las 20:05, Gary Johnson <gary...@spocom.com> escribi�:
>
> > On 2012-05-29, Pablo Gim�nez wrote:
> >> Hi all.
> >> I have an issue using vim in the termninal.
> >> Every time I go to Indert mode and try to sue the cursor it just
> >> begging to write the letter A,B,C,D and creates a new line.
> >> I have been digging and seems it is because of the internal definition
> >> of the termcap in Vim.
> >> So I tried the next:
> >> set term=builtin_ansi
> >>
> >> But then it is messing up the colors.
> >> The term is xterm-256color by default.
> >> Is there ane way to get the cursors working properly without changing
> >> the termn, or using the xterm terminal?
> >> I forgot to say I am using latest vim 7.3.
> >
> > The value of $TERM needs to be appropriate for the terminal you are
> > actually using.
> >
> > Vim uses $TERM to determine the terminal's capabilities and escape
> > sequences from your system's terminfo or termcap database. If the
> > value of $TERM is not correct, then Vim may obtain an incorrect
> > description of your arrow keys.
> >
> > What is the terminal you are using and what is the value of $TERM?
> I am using gnome terminal and xterm, for both TERM is set to xterm-256color

If I'm understanding you correctly, the arrow keys work in xterm but
not in GNOME Terminal.

I should have suggested this earlier: Try starting vim like this,

vim -N -u NONE

to see whether the behavior is due to either your ~/.vimrc or one of
your plugins.

One other thing you might try is executing

infocmp

to see if xterm-256color is properly defined on your system.

I run Vim 7.3.524 in a GNOME Terminal 2.26.3.1 on a Fedora 11 system
daily without problems, but my TERM is set to "xterm". I just tried
setting TERM to "xterm-256color" and the arrow keys worked fine in
both normal and insert modes. I don't see anything in the Profile
Preferences that would change the arrow key behavior.

Regards,
Gary

Pablo Giménez

unread,
May 30, 2012, 5:27:39 AM5/30/12
to vim...@googlegroups.com
2012/5/29 Gary Johnson <gary...@spocom.com>:
> On 2012-05-29, Pablo Giménez Pizarro wrote:
>> Enviado desde mi iPhone
>>
>> El 29 May 2012, a las 20:05, Gary Johnson <gary...@spocom.com> escribió:
>>
>> > On 2012-05-29, Pablo Giménez wrote:
>> >> Hi all.
>> >> I have an issue using vim in the termninal.
>> >> Every time I go to Indert mode and try to sue the cursor it just
>> >> begging to write the letter A,B,C,D and creates a new line.
>> >> I have been digging and seems it is because of the internal definition
>> >> of the termcap in Vim.
>> >> So I tried the next:
>> >> set term=builtin_ansi
>> >>
>> >> But then it is messing up the colors.
>> >> The term is xterm-256color by default.
>> >> Is there ane way to get the cursors working properly without changing
>> >> the termn, or using the xterm terminal?
>> >> I forgot  to say I am using latest vim 7.3.
>> >
>> > The value of $TERM needs to be appropriate for the terminal you are
>> > actually using.
>> >
>> > Vim uses $TERM to determine the terminal's capabilities and escape
>> > sequences from your system's terminfo or termcap database.  If the
>> > value of $TERM is not correct, then Vim may obtain an incorrect
>> > description of your arrow keys.
>> >
>> > What is the terminal you are using and what is the value of $TERM?
>> I am using gnome terminal and xterm, for both TERM is set to xterm-256color
>
> If I'm understanding you correctly, the arrow keys work in xterm but
> not in GNOME Terminal.
Nop it doesnt work in any terminal, xterm or gnome-terminal.
I also have mrxvt, but same problem.
>
> I should have suggested this earlier:  Try starting vim like this,
>
>    vim -N -u NONE
This is interesting to try.
Thanks.
Let you know guys hos it goes.
Thanks for the advice.
>
> to see whether the behavior is due to either your ~/.vimrc or one of
> your plugins.
>
> One other thing you might try is executing
>
>    infocmp
>
> to see if xterm-256color is properly defined on your system.
>
> I run Vim 7.3.524 in a GNOME Terminal 2.26.3.1 on a Fedora 11 system
> daily without problems, but my TERM is set to "xterm".  I just tried
> setting TERM to "xterm-256color" and the arrow keys worked fine in
> both normal and insert modes.  I don't see anything in the Profile
> Preferences that would change the arrow key behavior.
>
> Regards,
> Gary
>
> --
> 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



Pablo Giménez

unread,
May 30, 2012, 7:51:33 AM5/30/12
to vim...@googlegroups.com
Ja I got where is the problem.
I have these keymaps for the completion popmenu:
inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ?
"\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>"
: "\<PageUp>"

I got them from the vim wiki, so I am not sure why they are breaking
my cursors when working from a terminal.
It is supposed that if pop menu is not visible they just return the
same key isnt it?


2012/5/30 Pablo Giménez <pabl...@gmail.com>:

Gary Johnson

unread,
May 30, 2012, 1:29:50 PM5/30/12
to vim...@googlegroups.com
On 2012-05-30, Pablo Gim�nez wrote:

> 2012/5/30 Pablo Gim�nez:
> > 2012/5/29 Gary Johnson:
> >> On 2012-05-29, Pablo Gim�nez Pizarro wrote:
> >>> Enviado desde mi iPhone
> >>>
> >>> El 29 May 2012, a las 20:05, Gary Johnson escribi�:
> >>>
> >>> > On 2012-05-29, Pablo Gim�nez wrote:
> >>> >> Hi all.
> >>> >> I have an issue using vim in the termninal.
> >>> >> Every time I go to Indert mode and try to sue the cursor it just
> >>> >> begging to write the letter A,B,C,D and creates a new line.
> >>> >> I have been digging and seems it is because of the internal definition
> >>> >> of the termcap in Vim.
> >>> >> So I tried the next:
> >>> >> set term=builtin_ansi
> >>> >>
> >>> >> But then it is messing up the colors.
> >>> >> The term is xterm-256color by default.
> >>> >> Is there ane way to get the cursors working properly without changing
> >>> >> the termn, or using the xterm terminal?
> >>> >> I forgot �to say I am using latest vim 7.3.

> Ja I got where is the problem.
> I have these keymaps for the completion popmenu:
> inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
> inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
> inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
> inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
> inoremap <expr> <PageDown> pumvisible() ?
> "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
> inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>"
> : "\<PageUp>"
>
> I got them from the vim wiki, so I am not sure why they are breaking
> my cursors when working from a terminal.
> It is supposed that if pop menu is not visible they just return the
> same key isnt it?

Well, that was easy: I just executed the first inoremap above and
now when I use the arrow keys in insert mode I get A, B, C and D.

I don't have time at the moment to look at this more closely, but it
looks like possibly a bug. I can verify that the pumvisible()
function is returning the correct values. It appears that when an
Esc arrives in the input buffer, the process of handling it with the
inoremap disconnects it from the following characters so that it and
the following characters are no longer recognized as an escape
sequence. The behavior might be affected by 'timeout' and/or
'ttimeout', or maybe those options are being ignored when they
shouldn't be.

Maybe someone with more experience with these mappings can chime in.

Regards,
Gary

Christian Brabandt

unread,
May 31, 2012, 4:02:38 AM5/31/12
to vim...@googlegroups.com, vim...@googlegroups.com
I can reproduce the issue with this simple mapping:
inoremap <Esc> <Esc>

This breaks the cursor keys in terminal vim.

regards,
Christian

Pablo Giménez

unread,
May 31, 2012, 6:35:17 AM5/31/12
to vim...@googlegroups.com
So you guys thinks it is definitely a bug?

2012/5/31 Christian Brabandt <cbl...@256bit.org>:
> On Wed, May 30, 2012 19:29, Gary Johnson wrote:
Reply all
Reply to author
Forward
0 new messages