Search code examples
vimconfigurationdefaultfile-type

Why are Vim filetype options ON when ~/.vimrc is missing but OFF when it is present?


I am using Vim 8.1 on a Ubuntu system. Here are the three cases I have found.

Case 1

$ ls -l ~/.vimrc
ls: cannot access '/home/lone/.vimrc': No such file or directory
$ vim -u NONE +':filetype'
filetype detection:OFF  plugin:OFF  indent:OFF

Case 2

$ ls -l ~/.vimrc
ls: cannot access '/home/lone/.vimrc': No such file or directory
$ vim +':filetype'
filetype detection:ON  plugin:ON  indent:ON

Case 3

$ touch ~/.vimrc
$ ls -l ~/.vimrc
-rw-r--r-- 1 lone lone 0 Nov  2 18:41 /home/lone/.vimrc
$ vim +':filetype'
filetype detection:OFF  plugin:OFF  indent:OFF

Question

  1. Why is it that the filetype options are ON when ~/.vimrc is present but OFF when ~/.vimrc is present?
  2. Where in the Vim :help documentation can I find more about this behavior?

Solution

  • vim -u NONE starts vim without any config file and sets all options to default values.

    vim without ~/.vimrc reads configuration values from a system config file. Try /etc/vim/vimrc or /usr/share/vim/vimrc.

    See http://vimdoc.sourceforge.net/htmldoc/starting.html#initialization