Vim variants other than vim-tiny source /etc/vim/vimrc instead of /etc/vim/vimrc.tiny when invoked as vi (ie, Arrow keys not broken when running vi)

Bug #70569 reported by Constantine Evans
18
Affects Status Importance Assigned to Milestone
vim (Ubuntu)
Triaged
Low
Unassigned

Bug Description

When invoked as vi, vim.tiny sources /etc/vim/vimrc.tiny, which sets compatible so that the vi command runs like the original vi. According to several people on -devel, this is the desired behaviour for vim when invoked as vi, and the behaviour makes sense.

However, when another variant of vim, such as vim-full or vim-gnome is installed, the vi command sources /etc/vim/vimrc, which among other things sets nocompatible, so, for example, arrow keys work in insert mode. This is not the intended behaviour.

Revision history for this message
Micah Cowan (micahcowan) wrote :

While arrow-key support doesn't bother me particularly, I'd agree that invoking "vi" should bring up a traditional (compatible) vi. However, this should probably be discussed on the ubuntu-devel-discuss list, for the correct solution if not for the desired result.

vim.tiny does what it does only because it has been specifically patched by Debian to look for /etc/vim/vimrc.tiny when and only when it has been invoked as vi. None of the other compiled variants of vim (nor, of course, upstream) have such conditional rc-checking behavior. And I'm not sure that they should: that seems like the wrong way to go.

Instead, what should possibly happen is that the "vi" alternative should be linked directly to vim.tiny by default, instead of vim. That way, installing and update-alternativing a different vim variant would leave vi still invoking a compatible session.

Changed in vim:
status: Unconfirmed → Confirmed
Micah Cowan (micahcowan)
Changed in vim:
importance: Undecided → Low
Revision history for this message
Constantine Evans (cevans) wrote :

I actually did bring this up quite a while ago on ubuntu-devel (before the split), and the consensus seemed to be for the traditional mode.

Revision history for this message
tgpae (n-launchpad-net-ubuntu-tgape-org) wrote :

The problem is not what file the programs read. /etc/vim/vimrc should *not* set nocompatible by default. It should source a user-updateable file, such as possibly /etc/default/vim, which could have such a setting added.

This is not, IMHO, a developer preference, but a terminal user preference.

Revision history for this message
Daniel Hahler (blueyed) wrote :

I agree with tgpae.
On a minimal Ubuntu installation, with only vim-tiny, I've added an alias "vi=vim" to work around this.

Changed in vim:
status: Confirmed → Triaged
Revision history for this message
dmuir (dmuir) wrote :

This is a really annoying bug... I recently did a fresh install of Jaunty and I thought vi was broken since arrow keys were inserting characters, a behaviour I hadn't seen vi do before. AFIAK, most other *nix's use the noncompatible setup.
Not sure what could be done to make life easier for the user though. tgpae's suggestion although good, wouldn't help people like me who wouldn't have a clue what to edit to get the desired behaviour. To get around it, I installed vim (from suggestion here: https://answers.launchpad.net/ubuntu/+source/vim/+question/24182).
Doing it that way still feels like a hack though, but I'm glad it fixed the problem.

Revision history for this message
Constantine Evans (cevans) wrote :

dmuir, that isn't this bug, and it isn't actually a bug at all. All vim documentation, if I recall correctly, points out that "vi" is meant to run a traditional form of vi, which means compatible is set. The fact that "vi" runs vim with nocompatible set when anything other than vim-tiny is installed is actually wrong; if you want to run vim with nocompatible set, you are supposed to use "vim", not "vi".

Unfortunately, this has become so confused that any solution to this bug will inevitably upset some people. Personally, I know of very few people who would ever use vim in compatible mode, and that the best solution would probably be to change the documentation and make vi run vim with nocompatible set. However, it is worth pointing out that vim is not the only implementation of vi, and having it as vi could presumably lead to some confusion among a small set of people.

Revision history for this message
Robert North (russetrob) wrote :

I found this behaviour extremely annoying, but I cannot ever remember this bug on 80/90's HP, or Sun workstations.

Maybe that's because those companies, or the sysadmins mapped the arrow keys to something else.

If vim_tiny has to be kept, can I suggest doing 2 things....

1. Mapping arrow keys to something less annoying.
2. Including full full vi help in the ":help" command.
        my immediate response was to look up help.
        the help I found there was confusing.

An example of mapping arrow keys is here:
http://hea-www.harvard.edu/~fine/Tech/vi.html

Another option would be to map arrow keys to nothing at all!

Another hint that this is a bug people have resolved is here:
http://www.faqs.org/faqs/sgi/faq/apps/section-24.html
This suggests that at least for original vi, arrow mappings were available, but on slow terminals exhimited same behaviour as Ubuntu.

Revision history for this message
Will Gray (graywh) wrote :

Constantine, AFAIK, the Vim documentation makes no such claim. It does say that the presence of a vimrc will turn off 'compatible' mode, regardless of whether Vim was started as "vim" or "vi". Likewise, the absence of a vimrc will default 'compatible' to on (unless set otherwise in the system vimrc, etc.).

:h 'cp'

Revision history for this message
Will Gray (graywh) wrote :

tgpae, there *is* a user-editable file that can have a setting adding. It's called vimrc. For system-wide settings, /etc/vim/vimrc also sources /etc/vim/vimrc.local.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.