Why does Vim still have vi-compatibility mode?

480 views
Skip to first unread message

Dmitry Frank

unread,
May 29, 2014, 5:50:47 AM5/29/14
to vim...@vim.org

Could anyone explain why does Vim still have vi-compatibility mode? Why would one use it?

As a consequence, we have to keep set nocompatible in our .vimrc; there is much noise in docs like {not in Vi}, {Vi: no ++opt}, etc.

and I can't really understand why developers keep it so carefully.


Benjamin Klein

unread,
May 29, 2014, 6:09:21 AM5/29/14
to vim...@googlegroups.com
(Disclaimer: I'm not an official Vim developer and don't necessarily know the official reasons myself.)

Tim Pope brought up the "vi equivalent" issue when Neovim was announced, I think back in February.

"#1 concern about neovim is that dropping compatibility mode prevents OS's from shipping it as vi. That's a big perk of vim"

That could have something to do with it.

On the other hand, I am on OS X, which is one of those OSs. I installed Vim using Homebrew anyway -- and I don't actually often use many other computers than my own (though I realize that many must). So the "Vim is everywhere" argument, for me, has very little to do with why I use it, and is no argument (for me personally!) in favor of compatibility mode.

The mileage of the sane rest of the universe probably varies.

Ben

--
b

Sent from my iPhone

tux.

unread,
May 29, 2014, 6:41:44 AM5/29/14
to Dmitry Frank
Dmitry Frank schrob am Donnerstag, 29. Mai 2014 um 11:50 Zeit:

> and I can't really understand why developers keep it so carefully.

What's wrong with that?

If you don't want that, use NeoVim or something.

glts

unread,
May 29, 2014, 7:05:00 AM5/29/14
to vim...@googlegroups.com, vim...@vim.org
Hi,
vi is part of the POSIX standard, IEEE Std 1003.1.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html


--
David

Christian Brabandt

unread,
May 29, 2014, 7:46:30 AM5/29/14
to vim...@vim.org
On Do, 29 Mai 2014, Dmitry Frank wrote:

> Could anyone explain why does Vim still have vi-compatibility mode? Why
> would one use it?
>
> As a consequence, we have to keep set nocompatible in our .vimrc; there is

No:

,----[ :h 'cp' ]-
| When a |vimrc| or |gvimrc| file is found while Vim is starting up,
| this option is switched off, and all options that have not been
| modified will be set to the Vim defaults. Effectively, this means
| that when a |vimrc| or |gvimrc| file exists, Vim will use the Vim
| defaults, otherwise it will use the Vi defaults. (Note: This doesn't
| happen for the system-wide vimrc or gvimrc file, nor for a file given
| with the |-u| argument). Also see |compatible-default| and
| |posix-compliance|.
`----

Mit freundlichen Grüßen
Christian
--
Das Leben ist eine Treppe: Wir wissen nie, ob es mit uns aufwärts oder
abwärts geht.
-- Ernst R. Hauschka

Kerneels Roos

unread,
May 29, 2014, 8:18:13 AM5/29/14
to vim...@googlegroups.com

On 2014-05-29 01:46 PM, Christian Brabandt wrote:
> On Do, 29 Mai 2014, Dmitry Frank wrote:
>
>> Could anyone explain why does Vim still have vi-compatibility mode? Why
>> would one use it?
never forget your roots....
nor your humble beginnings.....
nor your grandpa! :p

>> As a consequence, we have to keep set nocompatible in our .vimrc; there is
> No:
>
> ,----[ :h 'cp' ]-
> | When a |vimrc| or |gvimrc| file is found while Vim is starting up,
> | this option is switched off, and all options that have not been
> | modified will be set to the Vim defaults. Effectively, this means
> | that when a |vimrc| or |gvimrc| file exists, Vim will use the Vim
> | defaults, otherwise it will use the Vi defaults. (Note: This doesn't
> | happen for the system-wide vimrc or gvimrc file, nor for a file given
> | with the |-u| argument). Also see |compatible-default| and
> | |posix-compliance|.
> `----
>
> Mit freundlichen Grüßen
> Christian

--
Kerneels Roos
Cell: +27 (0)79 696 6038
Tel: +27 (0)811 2108
LinkedIn: http://za.linkedin.com/in/kerneels

Skype: cornelis.roos

Tony Mechelynck

unread,
Jun 7, 2014, 10:08:20 PM6/7/14
to vim...@googlegroups.com
I think the basic reason is that Bram finds backwards compatibility
important, and I can't fault him with that. Anyway, as Christian said,
as soon as Vim finds your vimrc it will set 'nocompatible' (except when
using the -u option), so ":set nocompatible" isn't needed unless there
might be times when you would include your vimrc by means of the -u
option; and even then you may add -N on the same command-line to achieve
the same effect.

There may still be users around who came to Vim from Vi and who never
came around to use 'nocompatible' mode, or to set their customizations
by means of a vimrc rather than an exrc. I think I've met some such
people on vim_use occasionally.

Also, Vi is part of the POSIX standard, and that standard describes in
excruciating detail how the program must behave. See ":help
posix-compliance" for the details: when $VIM_POSIX is set, Vim will even
copy some details of Vi behaviour which Bram regards as clear bugs (and
which it doesn't copy in non-POSIX 'compatible' mode).

If you want 'nocompatible' mode, as I do, make sure to put the -N switch
on the Vim command-line whenever you also include -u (be it as -u NONE
or -u filename.vim) and also when you aren't sure that there is a .vimrc
or a _vimrc in your current $HOME directory.


Best regards,
Tony.
--
~
~
~
".signature" 4 lines, 50 characters written

Reply all
Reply to author
Forward
0 new messages