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