Permalink
Browse files

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.
  • Loading branch information...
brammool committed Jul 28, 2016
1 parent eac784e commit 8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Showing with 243 additions and 122 deletions.
  1. +2 −1 Filelist
  2. +109 −0 runtime/defaults.vim
  3. +21 −14 runtime/doc/options.txt
  4. +57 −32 runtime/doc/starting.txt
  5. +9 −1 runtime/evim.vim
  6. +7 −65 runtime/vimrc_example.vim
  7. +8 −5 src/Makefile
  8. +5 −0 src/feature.h
  9. +7 −4 src/main.c
  10. +3 −0 src/os_amiga.h
  11. +3 −0 src/os_dos.h
  12. +3 −0 src/os_mac.h
  13. +4 −0 src/os_unix.h
  14. +5 −0 src/version.c
@@ -526,8 +526,9 @@ RT_ALL = \
runtime/macros/urm/examples \
runtime/macros/urm/urm \
runtime/macros/urm/urm.vim \
runtime/mswin.vim \
runtime/defaults.vim \
runtime/evim.vim \
runtime/mswin.vim \
runtime/optwin.vim \
runtime/ftplugin.vim \
runtime/ftplugof.vim \
@@ -0,0 +1,109 @@
" The default vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2016 Jul 28
"
" This is loaded if no vimrc file was found.
" Except when Vim is run with "-u NONE" or "-C".
" Individual settings can be reverted with ":set option&".
" Other commands can be reverted as mentioned below.
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" Allow backspacing over everything in insert mode.
set backspace=indent,eol,start
set history=200 " keep 200 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set wildmenu " display completion matches in a status line
" Do incremental searching when it's possible to timeout.
if has('reltime')
set incsearch
endif
" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
" confusing.
set nrformats-=octal
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
if has('win32')
set guioptions-=t
endif
" Don't use Ex mode, use Q for formatting.
" Revert with ":unmap Q".
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
" Revert with ":iunmap <C-U>".
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine. By enabling it you
" can position the cursor, Visually select and scroll with the mouse.
if has('mouse')
set mouse=a

This comment has been minimized.

@derekschrock

derekschrock Nov 20, 2016

Can this be reverted to not set mouse=a? This seems a bit drastic of change for a default setting. For users without a .vimrc (root, new users, non-vim users) I think this causes more problems than it solves for purely ssh environments. I mainly use the native OS' (sshing-from) clipboard/select. With this set you're forced to have a ~/.vimrc mainly root.

This comment has been minimized.

@brammool

brammool via email Nov 21, 2016

Contributor

This comment has been minimized.

@derekschrock

derekschrock via email Nov 21, 2016

This comment has been minimized.

@brammool

brammool via email Nov 22, 2016

Contributor

This comment has been minimized.

@derekschrock

derekschrock via email Nov 23, 2016

This comment has been minimized.

@jamessan

jamessan Nov 23, 2016

Without enabling the mouse you can't position the cursor or use the scrollwheel in Vim. Since for the selection you can make it work with the shift key, I still think that setting the 'mouse' option by default is the best choice.

Except that there are a lot of people who don't know that holding shift makes the terminal handle the mouse instead of Vim. This was the biggest complaint I got when Debian got the updated packages, specifically because what they had been doing for many years stopped working and they didn't know how to fix it or work around it.

Also, when using the mouse in a console via gpm, holding shift doesn't override the behavior so those users have no work around. The update just broke behavior they were used it.

This comment has been minimized.

@chrisbra

chrisbra Nov 23, 2016

Member

Is that only a problem for people using su (e.g. using Vim as root)? Then perhaps a check for being root could help here?

This comment has been minimized.

@derekschrock

derekschrock via email Nov 23, 2016

This comment has been minimized.

@jamessan

jamessan Nov 23, 2016

It could be an issue for anyone that didn't have a .vimrc file.

Correct, and there are far more of those than I would have expected.

I think root would be the most popular of that class of users.

Right, so the environment that's most uncommonly used and typically for quick tasks now behaves quite differently than experience has taught for the past couple decades.

This comment has been minimized.

@vim-ml

vim-ml via email Nov 23, 2016

endif
" Switch syntax highlighting on when the terminal has colors or when using the
" GUI (which always has colors).
if &t_Co > 2 || has("gui_running")
" Revert with ":syntax off".
syntax on
" I like highlighting strings inside C comments.
" Revert with ":unlet c_comment_strings".
let c_comment_strings=1
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
" Revert with ":filetype off".
filetype plugin indent on
" Put these in an autocmd group, so that you can revert them with:
" ":augroup vimStartup | au! | augroup END"
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
" Revert with: ":delcommand DiffOrig".
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
if has('langmap') && exists('+langnoremap')
" Prevent that the langmap option applies to characters that result from a
" mapping. If unset (default), this may break plugins (but it's backward
" compatible).
set langnoremap
endif
@@ -1,4 +1,4 @@
*options.txt* For Vim version 7.4. Last change: 2016 Jul 12
*options.txt* For Vim version 7.4. Last change: 2016 Jul 28
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -887,7 +887,8 @@ A jump table for the options with a short description can be found at |Q_op|.
done with ":syntax on".
*'backspace'* *'bs'*
'backspace' 'bs' string (default "")
'backspace' 'bs' string (default "", set to "indent,eol,start"
in |defaults.vim|)
global
{not in Vi}
Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
@@ -1696,7 +1697,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'compatible'* *'cp'* *'nocompatible'* *'nocp'*
'compatible' 'cp' boolean (default on, off when a |vimrc| or |gvimrc|
file is found)
file is found, reset in |defaults.vim|)
global
{not in Vi}
This option has the effect of making Vim either more Vi-compatible, or
@@ -3725,8 +3726,10 @@ A jump table for the options with a short description can be found at |Q_op|.
screen.
*'guioptions'* *'go'*
'guioptions' 'go' string (default "egmrLtT" (MS-Windows),
"aegimrLtT" (GTK, Motif and Athena))
'guioptions' 'go' string (default "egmrLtT" (MS-Windows, "t" is
removed in |defaults.vim|),
"aegimrLtT" (GTK, Motif and Athena),
)
global
{not in Vi}
{only available when compiled with GUI enabled}
@@ -4048,7 +4051,8 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is reset when 'compatible' is set.
*'history'* *'hi'*
'history' 'hi' number (Vim default: 50, Vi default: 0)
'history' 'hi' number (Vim default: 50, Vi default: 0,
set to 200 in |defaults.vim|)
global
{not in Vi}
A history of ":" commands, and a history of previous search patterns
@@ -4300,7 +4304,8 @@ A jump table for the options with a short description can be found at |Q_op|.
evaluating 'includeexpr' |textlock|.
*'incsearch'* *'is'* *'noincsearch'* *'nois'*
'incsearch' 'is' boolean (default off)
'incsearch' 'is' boolean (default off, set in |defaults.vim| if the
+reltime feature is supported)
global
{not in Vi}
{not available when compiled without the
@@ -4684,7 +4689,7 @@ A jump table for the options with a short description can be found at |Q_op|.
< Warning: This deletes all menus that you defined yourself!
*'langnoremap'* *'lnr'* *'nolangnoremap'* *'nolnr'*
'langnoremap' 'lnr' boolean (default off)
'langnoremap' 'lnr' boolean (default off, set in |defaults.vim|)
global
{not in Vi}
{only available when compiled with the |+langmap|
@@ -5150,7 +5155,8 @@ A jump table for the options with a short description can be found at |Q_op|.
set and to the Vim default value when 'compatible' is reset.
*'mouse'* *E538*
'mouse' string (default "", "a" for GUI, MS-DOS and Win32)
'mouse' string (default "", "a" for GUI, MS-DOS and Win32,
set to "a" in |defaults.vim|)
global
{not in Vi}
Enable the use of the mouse. Only works for certain terminals
@@ -5316,7 +5322,8 @@ A jump table for the options with a short description can be found at |Q_op|.
Negative or zero value means no thread scheduling.
*'nrformats'* *'nf'*
'nrformats' 'nf' string (default "bin,octal,hex")
'nrformats' 'nf' string (default "bin,octal,hex",
set to "bin,hex" in |defaults.vim|)
local to buffer
{not in Vi}
This defines what bases Vim will consider for numbers when using the
@@ -5986,7 +5993,7 @@ A jump table for the options with a short description can be found at |Q_op|.
security reasons.
*'ruler'* *'ru'* *'noruler'* *'noru'*
'ruler' 'ru' boolean (default off)
'ruler' 'ru' boolean (default off, set in |defaults.vim|)
global
{not in Vi}
{not available when compiled without the
@@ -6619,8 +6626,8 @@ A jump table for the options with a short description can be found at |Q_op|.
"n" flag to 'cpoptions'.
*'showcmd'* *'sc'* *'noshowcmd'* *'nosc'*
'showcmd' 'sc' boolean (Vim default: on, off for Unix, Vi default:
off)
'showcmd' 'sc' boolean (Vim default: on, off for Unix,
Vi default: off, set in |defaults.vim|)
global
{not in Vi}
{not available when compiled without the
@@ -8377,7 +8384,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'*
'wildmenu' 'wmnu' boolean (default off)
'wildmenu' 'wmnu' boolean (default off, set in |defaults.vim|)
global
{not in Vi}
{not available if compiled without the |+wildmenu|
@@ -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,33 +962,54 @@ problems if you have a file with only <NL>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
encountered. This makes a difference when using things like "<CR>". 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
@@ -1,6 +1,6 @@
" Vim script for Evim key bindings
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2006 Mar 29
" Last Change: 2016 Jul 24
" Don't use Vi-compatible mode.
set nocompatible
@@ -63,4 +63,12 @@ if has("autocmd")
endif " has("autocmd")
" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
if has('syntax') && has('eval')
packadd matchit
endif
" vim: set sw=2 :
Oops, something went wrong.

0 comments on commit 8c08b5b

Please sign in to comment.