Using arrow keys in vim-tiny while in Insert mode introduces A,B,C,D into text

Bug #491615 reported by Vik on 2009-12-02
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
GNOME Terminal
Invalid
Undecided
Unassigned
vim (Ubuntu)
Undecided
Unassigned
Nominated for Karmic by anatoly techtonik
Nominated for Lucid by anatoly techtonik

Bug Description

Binary package hint: vim

Using vim-tiny after a default install is tricky. If you enter Insert mode and attempt to move the cursor with the keys, A,B,C or D is inserted. As Insert mode also will not let you move past the end of the line and the arrow keys won't let you move there it is impossible to add characters after the end of line unless you do editing gymnastics.

ProblemType: Bug
Architecture: i386
Date: Thu Dec 3 11:10:25 2009
DistroRelease: Ubuntu 9.10
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release i386 (20091028.5)
Package: vim-tiny 2:7.2.245-2ubuntu2
ProcEnviron:
 PATH=(custom, user)
 LANG=en_NZ.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-14.48-generic
SourcePackage: vim
Uname: Linux 2.6.31-14-generic i686
XsessionErrors:
 (gnome-settings-daemon:1826): GLib-CRITICAL **: g_propagate_error: assertion `src != NULL' failed
 (gnome-settings-daemon:1826): GLib-CRITICAL **: g_propagate_error: assertion `src != NULL' failed
 (polkit-gnome-authentication-agent-1:1896): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed
 (nautilus:1874): Eel-CRITICAL **: eel_preferences_get_boolean: assertion `preferences_is_initialized ()' failed
 (nautilus:3052): Eel-CRITICAL **: eel_preferences_get_boolean: assertion `preferences_is_initialized ()' failed

Vik (vik-catalyst) wrote :
anatoly techtonik (techtonik) wrote :

This is true for plain vim command running in gnome-terminal. Very annoying.

AfghanEagle (art-bravo321) wrote :

try this:

sudo apt-get install vim

solved the same issue i had and the one with backspace etc

James McCoy (jamessan) wrote :

Closing the bug as it is user error. vim-tiny defaults to running with the 'compatible' option set. Using ":set nocompatible" or ":set esckeys" will restore the expected behavior.

Changed in vim (Ubuntu):
status: New → Invalid
Vik (vik-catalyst) wrote :

Thank you for the explanation. This also explains why nano and pico are largely replacing vim-tiny.

anatoly techtonik (techtonik) wrote :

 What for is this 'compatible' option is set if it is incompatible even with default Ubuntu terminal?

sudo aptitude install vim

didn't solve the issue.

Changed in vim (Ubuntu):
status: Invalid → Incomplete
anatoly techtonik (techtonik) wrote :

I propose to make a `vim` default in Ubuntu user friendly.

Colin Watson (cjwatson) wrote :

Install the full 'vim' package if you want a user-friendly vi (complete with syntax highlighting and other bells and whistles); the vim-tiny package is for basic compatibility with traditional vi, which is what many sysadmins tell us they want, and one of the things the 'compatible' option includes is disabling the 'esckeys' option. We don't have space for the full vim package in a standard installation, but anyone who can cope with vi should be able to cope with installing it quite easily.

This isn't a gnome-terminal bug either - it's fine for it to send ESC O A on cursor-up.

Changed in vim (Ubuntu):
status: Incomplete → Won't Fix
Colin Watson (cjwatson) wrote :

Oh, and if installing vim didn't solve it then you must be doing something else wrong - are you invoking vim as vim, or as vi?

Changed in gnome-terminal:
status: New → Invalid
Vik (vik-catalyst) wrote :

@anatoly Seconded.

anatoly techtonik (techtonik) wrote :

Reinstalling vim with removing and then `sudo apt-get install vim` did nothing

$ cat .vimrc-save
set columns=130
colors desert

Who is the primary auditory of Ubuntu - sysadmins or users?

Changed in vim (Ubuntu):
status: Won't Fix → New
anatoly techtonik (techtonik) wrote :

Sysadmins are more advanced than users and know how to set compatibility mode for vim. Why can't sysadmins call `vim` as `vi`? I understand that this puts `vim` into compatibility mode they need.

If `vim` command is available on user system, it is unlikely that user will go through installing it again without specific knowledge of differences between `vim` and `vim-tiny` that, again, belongs to sysadmins.

James McCoy (jamessan) wrote :

Anatoly, Vim runs in 'compatible' mode by default. This isn't specific to vim-tiny. The way that you change this is by creating a ~/.vimrc file. The mere presence of this file tells Vim that you know you're using something other than vi and it changes the option to 'incompatible', allowing you to use arrow keys in insert mode.

The difference with vim-tiny is that it is solely targeted at base installs (which are typically run by sysadmins as they're setting up the system). Because of this, we only install the binary under the name vi, not vim. Also, we ensure that it runs in 'compatible' mode.

anatoly techtonik (techtonik) wrote :

Then on behalf of Ubuntu users I'd like to ask to run Vim in "user-friendly" mode by default leaving 'compatible' mode for cases when Vim executed as 'vi'.

"user-friendly" mode means that I can install Vim package and run Vim from local terminal as 'vim' in any Ubuntu installation under any user and use keys designed for navigation around text file without creating any additional configs.

Any objections? =)

Samium Gromoff (deepfire) wrote :

I second Anatoly on this issue.

I'd even suggest that 'vi' should default to the compatible mode as well.

Rationale: extremely user-visible functionality should work by default.

Favoring hjkl movement keys over arrows is, well, "so 1999". People expect better.

Will Gray (graywh) on 2010-05-06
Changed in vim (Ubuntu):
status: New → Invalid
anatoly techtonik (techtonik) wrote :

Will, may I ask you to summarize your decision?

Changed in vim (Ubuntu):
status: Invalid → Incomplete
Will Gray (graywh) wrote :

anatoly, it has already been explained why this is not a bug.

After installing the package "vim", Vim runs in 'nocompatible' mode by default and the cursor keys work.

anatoly techtonik (techtonik) wrote :

Will, did you actually check that the explanation is true yourself?

See comment #6

I've repeated in on 10.04:
sudo aptitude remove vim
sudo aptitude install vim

Entered vim on existing text file, pressed 'I', the cursor keys produce letters. A-up, B-down, D-left, C-right. See comment #11 for my .vimrc-save - I paste it again:

cat .vimrc-save
set columns=130
colors desert

Will Gray (graywh) wrote :

Yes, I did. My only guess is that you are doing some in a non-default way (e.g. by-passing /etc/vim/vimrc). How are you invoking vim? And why is your vimrc named .vimrc-save?

Peter Odding (peterodding) wrote :

I'm pretty sure there's a real bug somewhere deep inside of Ubuntu (maybe some system wide thing like termcap or whatever it's called) causing this behavior. I've used Ubuntu's Vim packages for years, always getting annoyed about the described bug.

1. I've created ~/.vimrc, it's nonempty and it's readable.

2. I always start Vim using the "vim" executable (hard link, symlink, whatever), never as "vi".

3. I've verified that, when the bug occurs, ":set compatible?" prints "set nocompatible".

4. The bug occurs when running Vim in either gnome-terminal or xterm (this is why it seems to be a system wide problem to me).

5. Recently I've started compiling Vim 7.3 based on the Mercurial repository at https://vim.googlecode.com/hg/ and even these builds exhibit the same exact problem.

6. I've found a workaround, though I still don't understand how the hell it works after using it for several months:

Add the following lines to your ~/.vimrc script:

if $TERM =~ 'xterm\|screen'
  " None of the cursor keys work out of the box in Vim while in insert mode
  " using gnome-terminal/xterm but once I manually fix <Up> the other cursor
  " keys start working magically?!
  imap <Esc>[A <Up>
endif

One last thing, I'm still running Ubuntu 9.10 (Karmic) so can't confirm whether this problem still exists for newer releases.

Will Gray (graywh) wrote :

@Peter

On Ubuntu 9.10 with vim 2:7.2.245-2ubuntu2, run "TERM=xterm vim.basic -u NONE -N" in an xterm--arrow keys work just fine in insert mode.

Peter Odding (peterodding) wrote :

@Will:

You're right. The arrow keys also work when I log-in as a user without a ~/.vimrc file and manually :set nocompatible after starting Vim. Sorry for the noise I guess.

One thing though, the above implies to me that the problem is inside my own ~/.vimrc script (correct?) but I don't understand what kind of setting could cause this, and how the workaround I posted above could possibly restore the cursor key functionality?!

anatoly techtonik (techtonik) wrote :

I've finally resolved my problem with `vim` working in "compatible mode". It was caused by _missing_ configuration files in /etc/vim I don't know why there were no files in /etc/vim - my Ubuntu installation is rather old. I've recorded my findings in bug #667235 to make default behavior of `vi` and `vim` not to be affected by shared configuration files. The bug also portrays another side of problem that `vi` (not `vim`) starts to run in "nocompatible mode" after `vim` is installed.

Vik, Samium, Peter, if the following fixes the problem with "nocompatible" mode in _vim_ for you, I'll mark this bug as duplucate of #667235
$ sudo aptitude purge vim vim-common vim-gnome vim-gui-common vim-runtime vim-tiny
$ sudo aptitude install vim

Launchpad Janitor (janitor) wrote :

[Expired for vim (Ubuntu) because there has been no activity for 60 days.]

Changed in vim (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers