From 8c08b5b569e2a9e9f63dea514591ecfa2d3bb392 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 28 Jul 2016 22:24:15 +0200 Subject: patch 7.4.2111 Problem: Defaults are very conservative. Solution: Move settings from vimrc_example.vim to defaults.vim. Load defaults.vim if no .vimrc was found. --- runtime/doc/starting.txt | 89 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 32 deletions(-) (limited to 'runtime/doc/starting.txt') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index b613cf0561..256aaaddec 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Jul 03 +*starting.txt* For Vim version 7.4. Last change: 2016 Jul 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -806,13 +806,13 @@ accordingly. Vim proceeds in this order: For the Macintosh the $VIMRUNTIME/macmap.vim is read. *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC* - c. Four places are searched for initializations. The first that exists + c. Five places are searched for initializations. The first that exists is used, the others are ignored. The $MYVIMRC environment variable is set to the file that was first found, unless $MYVIMRC was already set and when using VIMINIT. - - The environment variable VIMINIT (see also |compatible-default|) (*) - The value of $VIMINIT is used as an Ex command line. - - The user vimrc file(s): + I The environment variable VIMINIT (see also |compatible-default|) (*) + The value of $VIMINIT is used as an Ex command line. + II The user vimrc file(s): "$HOME/.vimrc" (for Unix and OS/2) (*) "$HOME/.vim/vimrc" (for Unix and OS/2) (*) "s:.vimrc" (for Amiga) (*) @@ -829,13 +829,14 @@ accordingly. Vim proceeds in this order: Note: For MS-DOS and Win32, "$HOME" is checked first. If no "_vimrc" or ".vimrc" is found there, "$VIM" is tried. See |$VIM| for when $VIM is not set. - - The environment variable EXINIT. - The value of $EXINIT is used as an Ex command line. - - The user exrc file(s). Same as for the user vimrc file, but with - "vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is - used, depending on the system. And without the (*)! - - You would usually have "syntax on" and/or "filetype on" commands, - which trigger initializing filetype detection, see |syntax-loading|. + III The environment variable EXINIT. + The value of $EXINIT is used as an Ex command line. + IV The user exrc file(s). Same as for the user vimrc file, but with + "vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is + used, depending on the system. And without the (*)! + V The default vimrc file, $VIMRUNTIME/defaults.vim. This sets up + options values and has "syntax on" and "filetype on" commands, + which is what most new users will want. See |defaults.vim|. d. If the 'exrc' option is on (which is not the default), the current directory is searched for three files. The first that exists is used, @@ -912,6 +913,9 @@ accordingly. Vim proceeds in this order: The |v:vim_did_enter| variable is set to 1. The |VimEnter| autocommands are executed. +The $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or +gvimrc file. + Some hints on using initializations: Standard setup: @@ -958,16 +962,29 @@ problems if you have a file with only s and have a line like *compatible-default* When Vim starts, the 'compatible' option is on. This will be used when Vim -starts its initializations. But as soon as a user vimrc file is found, or a -vimrc file in the current directory, or the "VIMINIT" environment variable is -set, it will be set to 'nocompatible'. This has the side effect of setting or -resetting other options (see 'compatible'). But only the options that have -not been set or reset will be changed. This has the same effect like the -value of 'compatible' had this value when starting Vim. Note that this -doesn't happen for the system-wide vimrc file nor when Vim was started with -the |-u| command line argument. It does also happen for gvimrc files. The -$MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or gvimrc -file. +starts its initializations. But as soon as: +- a user vimrc file is found, or +- a vimrc file in the current directory, or +- the "VIMINIT" environment variable is set, or +- the "-N" command line argument is given, or + even when no vimrc file exists. +- the |defaults.vim| script is loaded, or +- gvimrc file was found, +then it will be set to 'nocompatible'. + +Note that this does NOT happen when a system-wide vimrc file was found. + +This has the side effect of setting or resetting other options (see +'compatible'). But only the options that have not been set or reset will be +changed. This has the same effect like the value of 'compatible' had this +value when starting Vim. + +'compatible is NOT reset, and |defaults.vim| is not loaded: +- when Vim was started with the |-u| command line argument, especially with + "-u NONE", or +- when started with the |-C| command line argument, or +- when the name of the executable ends in "ex". (This has been done to make + Vim behave like "ex", when it is started as "ex") But there is a side effect of setting or resetting 'compatible' at the moment a .vimrc file is found: Mappings are interpreted the moment they are @@ -975,16 +992,24 @@ encountered. This makes a difference when using things like "". If the mappings depend on a certain value of 'compatible', set or reset it before giving the mapping. -The above behavior can be overridden in these ways: -- If the "-N" command line argument is given, 'nocompatible' will be used, - even when no vimrc file exists. -- If the "-C" command line argument is given, 'compatible' will be used, even - when a vimrc file exists. -- If the "-u {vimrc}" argument is used, 'compatible' will be used. -- When the name of the executable ends in "ex", then this works like the "-C" - argument was given: 'compatible' will be used, even when a vimrc file - exists. This has been done to make Vim behave like "ex", when it is started - as "ex". + *defaults.vim* +If Vim is started normally and no user vimrc file is found, the +$VIMRUTIME/defaults.vim script is loaded. This will set 'compatible' off, +switch on syntax highlighting and a few more things. See the script for +details. NOTE: this is done since Vim 8.0, not in Vim 7.4. (it was added in +patch 7.4.2111 to be exact). + +This should work well for new Vim users. If you create your own .vimrc, it is +recommended to add this line somewhere near the top: > + source $VIMRUNTIME/defaults.vim +Then Vim works like before you had a .vimrc. Copying $VIMRUNTIME/vimrc_example +is way to do this. Alternatively, you can copy defaults.vim to your .vimrc +and modify it. + +If you don't like some of the defaults, you can still source defaults.vim and +revert individual settings. See the defaults.vim file for hints on how to +revert each item. + Avoiding trojan horses: *trojan-horse* While reading the "vimrc" or the "exrc" file in the current directory, some -- cgit v1.2.3