1- *starting.txt* For Vim version 7.4. Last change: 2016 Jul 03
1+ *starting.txt* For Vim version 7.4. Last change: 2016 Jul 28
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -807,13 +807,13 @@ accordingly. Vim proceeds in this order:
807807 MacVim.app, this only applies to the older Carbon version).
808808
809809 *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC*
810- c. Four places are searched for initializations. The first that exists
810+ c. Five places are searched for initializations. The first that exists
811811 is used, the others are ignored. The $MYVIMRC environment variable is
812812 set to the file that was first found, unless $MYVIMRC was already set
813813 and when using VIMINIT.
814- - The environment variable VIMINIT (see also | compatible-default | ) (*)
815- The value of $VIMINIT is used as an Ex command line.
816- - The user vimrc file(s):
814+ I The environment variable VIMINIT (see also | compatible-default | ) (*)
815+ The value of $VIMINIT is used as an Ex command line.
816+ II The user vimrc file(s):
817817 "$HOME/.vimrc" (for Unix and OS/2) (*)
818818 "$HOME/.vim/vimrc" (for Unix and OS/2) (*)
819819 "s:.vimrc" (for Amiga) (*)
@@ -830,13 +830,14 @@ accordingly. Vim proceeds in this order:
830830 Note: For MS-DOS and Win32, "$HOME" is checked first. If no
831831 "_vimrc" or ".vimrc" is found there, "$VIM" is tried.
832832 See | $VIM | for when $VIM is not set.
833- - The environment variable EXINIT.
834- The value of $EXINIT is used as an Ex command line.
835- - The user exrc file(s). Same as for the user vimrc file, but with
836- "vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is
837- used, depending on the system. And without the (*)!
838- - You would usually have "syntax on" and/or "filetype on" commands,
839- which trigger initializing filetype detection, see | syntax-loading | .
833+ III The environment variable EXINIT.
834+ The value of $EXINIT is used as an Ex command line.
835+ IV The user exrc file(s). Same as for the user vimrc file, but with
836+ "vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is
837+ used, depending on the system. And without the (*)!
838+ V The default vimrc file, $VIMRUNTIME/defaults.vim. This sets up
839+ options values and has "syntax on" and "filetype on" commands,
840+ which is what most new users will want. See | defaults.vim | .
840841
841842 d. If the 'exrc' option is on (which is not the default), the current
842843 directory is searched for three files. The first that exists is used,
@@ -913,6 +914,9 @@ accordingly. Vim proceeds in this order:
913914 The | v:vim_did_enter | variable is set to 1.
914915 The | VimEnter | autocommands are executed.
915916
917+ The $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or
918+ gvimrc file.
919+
916920Some hints on using initializations:
917921
918922Standard setup:
@@ -959,33 +963,54 @@ problems if you have a file with only <NL>s and have a line like
959963
960964 *compatible-default*
961965When Vim starts, the 'compatible' option is on. This will be used when Vim
962- starts its initializations. But as soon as a user vimrc file is found, or a
963- vimrc file in the current directory, or the "VIMINIT" environment variable is
964- set, it will be set to 'nocompatible' . This has the side effect of setting or
965- resetting other options (see 'compatible' ). But only the options that have
966- not been set or reset will be changed. This has the same effect like the
967- value of 'compatible' had this value when starting Vim. Note that this
968- doesn't happen for the system-wide vimrc file nor when Vim was started with
969- the | -u | command line argument. It does also happen for gvimrc files. The
970- $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or gvimrc
971- file.
966+ starts its initializations. But as soon as:
967+ - a user vimrc file is found, or
968+ - a vimrc file in the current directory, or
969+ - the "VIMINIT" environment variable is set, or
970+ - the "-N" command line argument is given, or
971+ even when no vimrc file exists.
972+ - the | defaults.vim | script is loaded, or
973+ - gvimrc file was found,
974+ then it will be set to 'nocompatible' .
975+
976+ Note that this does NOT happen when a system-wide vimrc file was found.
977+
978+ This has the side effect of setting or resetting other options (see
979+ 'compatible' ). But only the options that have not been set or reset will be
980+ changed. This has the same effect like the value of 'compatible' had this
981+ value when starting Vim.
982+
983+ 'compatible is NOT reset, and | defaults.vim | is not loaded:
984+ - when Vim was started with the | -u | command line argument, especially with
985+ "-u NONE", or
986+ - when started with the | -C | command line argument, or
987+ - when the name of the executable ends in "ex". (This has been done to make
988+ Vim behave like "ex", when it is started as "ex")
972989
973990But there is a side effect of setting or resetting 'compatible' at the moment
974991a .vimrc file is found: Mappings are interpreted the moment they are
975992encountered. This makes a difference when using things like "<CR> ". If the
976993mappings depend on a certain value of 'compatible' , set or reset it before
977994giving the mapping.
978995
979- The above behavior can be overridden in these ways:
980- - If the "-N" command line argument is given, 'nocompatible' will be used,
981- even when no vimrc file exists.
982- - If the "-C" command line argument is given, 'compatible' will be used, even
983- when a vimrc file exists.
984- - If the "-u {vimrc} " argument is used, 'compatible' will be used.
985- - When the name of the executable ends in "ex", then this works like the "-C"
986- argument was given: 'compatible' will be used, even when a vimrc file
987- exists. This has been done to make Vim behave like "ex", when it is started
988- as "ex".
996+ *defaults.vim*
997+ If Vim is started normally and no user vimrc file is found, the
998+ $VIMRUTIME/defaults.vim script is loaded. This will set 'compatible' off,
999+ switch on syntax highlighting and a few more things. See the script for
1000+ details. NOTE: this is done since Vim 8.0, not in Vim 7.4. (it was added in
1001+ patch 7.4.2111 to be exact).
1002+
1003+ This should work well for new Vim users. If you create your own .vimrc, it is
1004+ recommended to add this line somewhere near the top: >
1005+ source $VIMRUNTIME/defaults.vim
1006+ Then Vim works like before you had a .vimrc. Copying $VIMRUNTIME/vimrc_example
1007+ is way to do this. Alternatively, you can copy defaults.vim to your .vimrc
1008+ and modify it.
1009+
1010+ If you don't like some of the defaults, you can still source defaults.vim and
1011+ revert individual settings. See the defaults.vim file for hints on how to
1012+ revert each item.
1013+
9891014
9901015Avoiding trojan horses: *trojan-horse*
9911016While reading the "vimrc" or the "exrc" file in the current directory, some
0 commit comments