xref: /vim-8.2.3635/runtime/defaults.vim (revision cd5c8f82)
1" The default vimrc file.
2"
3" Maintainer:	Bram Moolenaar <[email protected]>
4" Last change:	2017 Apr 01
5"
6" This is loaded if no vimrc file was found.
7" Except when Vim is run with "-u NONE" or "-C".
8" Individual settings can be reverted with ":set option&".
9" Other commands can be reverted as mentioned below.
10
11" When started as "evim", evim.vim will already have done these settings.
12if v:progname =~? "evim"
13  finish
14endif
15
16" Bail out if something that ran earlier, e.g. a system wide vimrc, does not
17" want Vim to use these default values.
18if exists('skip_defaults_vim')
19  finish
20endif
21
22" Use Vim settings, rather than Vi settings (much better!).
23" This must be first, because it changes other options as a side effect.
24" Avoid side effects when it was already reset.
25if &compatible
26  set nocompatible
27endif
28
29" When the +eval feature is missing, the set command above will be skipped.
30" Use a trick to reset compatible only when the +eval feature is missing.
31if 1
32  nnoremap : :"
33endif
34silent normal :set nocompatible
35if 1
36  nunmap :
37endif
38
39" Allow backspacing over everything in insert mode.
40set backspace=indent,eol,start
41
42set history=200		" keep 200 lines of command line history
43set ruler		" show the cursor position all the time
44set showcmd		" display incomplete commands
45set wildmenu		" display completion matches in a status line
46
47set ttimeout		" time out for key codes
48set ttimeoutlen=100	" wait up to 100ms after Esc for special key
49
50" Show @@@ in the last line if it is truncated.
51set display=truncate
52
53" Show a few lines of context around the cursor.  Note that this makes the
54" text scroll if you mouse-click near the start or end of the window.
55set scrolloff=5
56
57" Do incremental searching when it's possible to timeout.
58if has('reltime')
59  set incsearch
60endif
61
62" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
63" confusing.
64set nrformats-=octal
65
66" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
67if has('win32')
68  set guioptions-=t
69endif
70
71" Don't use Ex mode, use Q for formatting.
72" Revert with ":unmap Q".
73map Q gq
74
75" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
76" so that you can undo CTRL-U after inserting a line break.
77" Revert with ":iunmap <C-U>".
78inoremap <C-U> <C-G>u<C-U>
79
80" In many terminal emulators the mouse works just fine.  By enabling it you
81" can position the cursor, Visually select and scroll with the mouse.
82if has('mouse')
83  set mouse=a
84endif
85
86" Switch syntax highlighting on when the terminal has colors or when using the
87" GUI (which always has colors).
88if &t_Co > 2 || has("gui_running")
89  " Revert with ":syntax off".
90  syntax on
91
92  " I like highlighting strings inside C comments.
93  " Revert with ":unlet c_comment_strings".
94  let c_comment_strings=1
95endif
96
97" Only do this part when compiled with support for autocommands.
98if has("autocmd")
99
100  " Enable file type detection.
101  " Use the default filetype settings, so that mail gets 'tw' set to 72,
102  " 'cindent' is on in C files, etc.
103  " Also load indent files, to automatically do language-dependent indenting.
104  " Revert with ":filetype off".
105  filetype plugin indent on
106
107  " Put these in an autocmd group, so that you can revert them with:
108  " ":augroup vimStartup | au! | augroup END"
109  augroup vimStartup
110    au!
111
112    " When editing a file, always jump to the last known cursor position.
113    " Don't do it when the position is invalid or when inside an event handler
114    " (happens when dropping a file on gvim).
115    autocmd BufReadPost *
116      \ if line("'\"") >= 1 && line("'\"") <= line("$") |
117      \   exe "normal! g`\"" |
118      \ endif
119
120  augroup END
121
122endif " has("autocmd")
123
124" Convenient command to see the difference between the current buffer and the
125" file it was loaded from, thus the changes you made.
126" Only define it when not defined already.
127" Revert with: ":delcommand DiffOrig".
128if !exists(":DiffOrig")
129  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
130		  \ | wincmd p | diffthis
131endif
132
133if has('langmap') && exists('+langremap')
134  " Prevent that the langmap option applies to characters that result from a
135  " mapping.  If set (default), this may break plugins (but it's backward
136  " compatible).
137  set nolangremap
138endif
139