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