In .vimrc, `set nocompatible` is completely useless?

Several users on this epic question have added the following to .vimrc :

 " Necesary for lots of cool vim things set nocompatible 

But is it really necessary? From the docs:

 'compatible' 'cp' boolean (default on, off when a |vimrc| or |gvimrc| file is found) 

If set nocompatible goes to .vimrc , it means that there is a .vimrc file that seems to be pointless.

+62
vim
May 01 '11 at a.m.
source share
4 answers

If it is a system-wide vimrc, this option will not be disabled. So, if you are changing the system-wide vimrc and want it, you need to install it.

In the documentation section * compatible-default * (highlighted by me):

When Vim starts, the "compatible" option is enabled. This will be used when Vim starts initialization. But as soon as the user vimrc file is found, or the vimrc file in the current one or the "VIMINIT" environment variable is set, it will be set to "nocompatible".

Another difference is that "nocompatible" overrules are explicitly set, calling vim with the -C flag . .

In any other scenario, yes, setting "nocompatible" in your vimrc is noop.

In the end, I think it's just a "better than sorry" question.

+48
May 01 '11 at 12:43 a.m.
source share

Many people share their .vimrc files on GitHub, and I sometimes check the settings without replacing my .vimrc file. vim allows me to do this with the -u flag.

 vim -u test_vimrc 

From vim ": help nocompatible"

(Note: This does not occur for the system-wide vimrc or gvimrc file, nor for the file specified with | -u | argument).

This means that if you share your .vimrc with someone and they use the -u flag to download your file, vim will not be configured as if the file was named .vimrc and located in your home directory.

+14
Mar 20 '14 at 20:06
source share

I used vim in Cygwin on a Windows virtual machine, and every time I was in Insert mode, pressing the arrow keys meant that instead of vim, "A", "B", "C" or "D" were printed on the screen instead of scrolling. I found a forum that said installing vim in incompatible mode would fix it. Fortunately, this happened.

I put "set nocompatible" in my ~ / .vimrc file and the problem did not disappear. So perhaps this is not 100% useless.

+5
Oct 22 '13 at
source share

Based on what Johnny pointed out above, I was just surprised when I just found THIS:

 $ cat /usr/share/vim/vimrc.tiny " Debian system-wide default configuration Vim set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after set compatible 

ARGH !!!

No, I did not expect this. Debian (or Debian Unstable aka Ubuntu) REALLY SHOULD put a nightmare on their users by overriding the default setting using install compatible . I hope you now find out why when you go from FreeBSD, the first thing you need to do is to override the system-wide setting by putting set nocompatible in your own ~/.vimrc . Because otherwise you just create letters, and you won’t be able to move the cursor the way you are used to.

I think this is a terrible idea. In other words, this set compatible line should be removed from the system-wide vimrc.tiny both Debian and Ubuntu, because it will annoy new users who are not as smart as knowing how to make the cursor keys work. Such things make them nano and others because of such completely meaningless blockers!

I would really like to talk to the dude who once propagated this change to a system-wide resource file in Debian. And maybe to people who fully recognized his change.

Johnny is right: on your personal computer, you can delete the specified line from the system-wide .vimrc (if any) and touch the empty .vimrc on $ HOME . Thanks so much for pointing this out and then cluttering up again. Note that you MUST have this ~/.vimrc (even if empty!), Since otherwise you would not be able to use cursors without explicitly entering set nocompatible .

0
Jan 22 '16 at 23:57
source share



All Articles