Mercurial > vim
comparison runtime/doc/starting.txt @ 9669:284b4eb307fc v7.4.2111
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 28 22:24:15 2016 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 28 Jul 2016 22:30:05 +0200 |
parents | be72f4201a1d |
children | 35ce559b8553 |
comparison
equal
deleted
inserted
replaced
9668:7d1ab1664b75 | 9669:284b4eb307fc |
---|---|
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 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
804 automatic resetting of 'compatible' is only done later. Add a ":set | 804 automatic resetting of 'compatible' is only done later. Add a ":set |
805 nocp" command if you like. | 805 nocp" command if you like. |
806 For the Macintosh the $VIMRUNTIME/macmap.vim is read. | 806 For the Macintosh the $VIMRUNTIME/macmap.vim is read. |
807 | 807 |
808 *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC* | 808 *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 |
810 is used, the others are ignored. The $MYVIMRC environment variable is | 810 is used, the others are ignored. The $MYVIMRC environment variable is |
811 set to the file that was first found, unless $MYVIMRC was already set | 811 set to the file that was first found, unless $MYVIMRC was already set |
812 and when using VIMINIT. | 812 and when using VIMINIT. |
813 - The environment variable VIMINIT (see also |compatible-default|) (*) | 813 I The environment variable VIMINIT (see also |compatible-default|) (*) |
814 The value of $VIMINIT is used as an Ex command line. | 814 The value of $VIMINIT is used as an Ex command line. |
815 - The user vimrc file(s): | 815 II The user vimrc file(s): |
816 "$HOME/.vimrc" (for Unix and OS/2) (*) | 816 "$HOME/.vimrc" (for Unix and OS/2) (*) |
817 "$HOME/.vim/vimrc" (for Unix and OS/2) (*) | 817 "$HOME/.vim/vimrc" (for Unix and OS/2) (*) |
818 "s:.vimrc" (for Amiga) (*) | 818 "s:.vimrc" (for Amiga) (*) |
819 "home:.vimrc" (for Amiga) (*) | 819 "home:.vimrc" (for Amiga) (*) |
820 "home:vimfiles:vimrc" (for Amiga) (*) | 820 "home:vimfiles:vimrc" (for Amiga) (*) |
827 system is used. For MS-DOS and Win32 ".vimrc" is checked | 827 system is used. For MS-DOS and Win32 ".vimrc" is checked |
828 after "_vimrc", in case long file names are used. | 828 after "_vimrc", in case long file names are used. |
829 Note: For MS-DOS and Win32, "$HOME" is checked first. If no | 829 Note: For MS-DOS and Win32, "$HOME" is checked first. If no |
830 "_vimrc" or ".vimrc" is found there, "$VIM" is tried. | 830 "_vimrc" or ".vimrc" is found there, "$VIM" is tried. |
831 See |$VIM| for when $VIM is not set. | 831 See |$VIM| for when $VIM is not set. |
832 - The environment variable EXINIT. | 832 III The environment variable EXINIT. |
833 The value of $EXINIT is used as an Ex command line. | 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 | 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 | 835 "vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is |
836 used, depending on the system. And without the (*)! | 836 used, depending on the system. And without the (*)! |
837 - You would usually have "syntax on" and/or "filetype on" commands, | 837 V The default vimrc file, $VIMRUNTIME/defaults.vim. This sets up |
838 which trigger initializing filetype detection, see |syntax-loading|. | 838 options values and has "syntax on" and "filetype on" commands, |
839 which is what most new users will want. See |defaults.vim|. | |
839 | 840 |
840 d. If the 'exrc' option is on (which is not the default), the current | 841 d. If the 'exrc' option is on (which is not the default), the current |
841 directory is searched for three files. The first that exists is used, | 842 directory is searched for three files. The first that exists is used, |
842 the others are ignored. | 843 the others are ignored. |
843 - The file ".vimrc" (for Unix, Amiga and OS/2) (*) | 844 - The file ".vimrc" (for Unix, Amiga and OS/2) (*) |
910 If the 'insertmode' option is set, Insert mode is entered. | 911 If the 'insertmode' option is set, Insert mode is entered. |
911 The starting flag is reset, has("vim_starting") will now return zero. | 912 The starting flag is reset, has("vim_starting") will now return zero. |
912 The |v:vim_did_enter| variable is set to 1. | 913 The |v:vim_did_enter| variable is set to 1. |
913 The |VimEnter| autocommands are executed. | 914 The |VimEnter| autocommands are executed. |
914 | 915 |
916 The $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or | |
917 gvimrc file. | |
918 | |
915 Some hints on using initializations: | 919 Some hints on using initializations: |
916 | 920 |
917 Standard setup: | 921 Standard setup: |
918 Create a vimrc file to set the default settings and mappings for all your edit | 922 Create a vimrc file to set the default settings and mappings for all your edit |
919 sessions. Put it in a place so that it will be found by 3b: | 923 sessions. Put it in a place so that it will be found by 3b: |
956 problems if you have a file with only <NL>s and have a line like | 960 problems if you have a file with only <NL>s and have a line like |
957 ":map xx yy^M". The trailing ^M will be ignored. | 961 ":map xx yy^M". The trailing ^M will be ignored. |
958 | 962 |
959 *compatible-default* | 963 *compatible-default* |
960 When Vim starts, the 'compatible' option is on. This will be used when Vim | 964 When 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 | 965 starts its initializations. But as soon as: |
962 vimrc file in the current directory, or the "VIMINIT" environment variable is | 966 - a user vimrc file is found, or |
963 set, it will be set to 'nocompatible'. This has the side effect of setting or | 967 - a vimrc file in the current directory, or |
964 resetting other options (see 'compatible'). But only the options that have | 968 - the "VIMINIT" environment variable is set, or |
965 not been set or reset will be changed. This has the same effect like the | 969 - the "-N" command line argument is given, or |
966 value of 'compatible' had this value when starting Vim. Note that this | 970 even when no vimrc file exists. |
967 doesn't happen for the system-wide vimrc file nor when Vim was started with | 971 - the |defaults.vim| script is loaded, or |
968 the |-u| command line argument. It does also happen for gvimrc files. The | 972 - gvimrc file was found, |
969 $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or gvimrc | 973 then it will be set to 'nocompatible'. |
970 file. | 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") | |
971 | 988 |
972 But there is a side effect of setting or resetting 'compatible' at the moment | 989 But there is a side effect of setting or resetting 'compatible' at the moment |
973 a .vimrc file is found: Mappings are interpreted the moment they are | 990 a .vimrc file is found: Mappings are interpreted the moment they are |
974 encountered. This makes a difference when using things like "<CR>". If the | 991 encountered. This makes a difference when using things like "<CR>". If the |
975 mappings depend on a certain value of 'compatible', set or reset it before | 992 mappings depend on a certain value of 'compatible', set or reset it before |
976 giving the mapping. | 993 giving the mapping. |
977 | 994 |
978 The above behavior can be overridden in these ways: | 995 *defaults.vim* |
979 - If the "-N" command line argument is given, 'nocompatible' will be used, | 996 If Vim is started normally and no user vimrc file is found, the |
980 even when no vimrc file exists. | 997 $VIMRUTIME/defaults.vim script is loaded. This will set 'compatible' off, |
981 - If the "-C" command line argument is given, 'compatible' will be used, even | 998 switch on syntax highlighting and a few more things. See the script for |
982 when a vimrc file exists. | 999 details. NOTE: this is done since Vim 8.0, not in Vim 7.4. (it was added in |
983 - If the "-u {vimrc}" argument is used, 'compatible' will be used. | 1000 patch 7.4.2111 to be exact). |
984 - When the name of the executable ends in "ex", then this works like the "-C" | 1001 |
985 argument was given: 'compatible' will be used, even when a vimrc file | 1002 This should work well for new Vim users. If you create your own .vimrc, it is |
986 exists. This has been done to make Vim behave like "ex", when it is started | 1003 recommended to add this line somewhere near the top: > |
987 as "ex". | 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 | |
988 | 1013 |
989 Avoiding trojan horses: *trojan-horse* | 1014 Avoiding trojan horses: *trojan-horse* |
990 While reading the "vimrc" or the "exrc" file in the current directory, some | 1015 While reading the "vimrc" or the "exrc" file in the current directory, some |
991 commands can be disabled for security reasons by setting the 'secure' option. | 1016 commands can be disabled for security reasons by setting the 'secure' option. |
992 This is always done when executing the command from a tags file. Otherwise it | 1017 This is always done when executing the command from a tags file. Otherwise it |