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