blob: 0ff834a2a042301ac2c2ca66982105dc24c8f5ff [file] [log] [blame]
Bram Moolenaar8c08b5b2016-07-28 22:24:15 +02001" The default vimrc file.
2"
3" Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar4427db92016-08-28 14:39:44 +02004" Last change: 2016 Aug 28
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
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
Bram Moolenaare07e7972016-08-20 19:22:16 +020028set ttimeout " time out for key codes
29set ttimeoutlen=100 " wait up to 100ms after Esc for special key
30
Bram Moolenaarb9a46fe2016-07-29 18:13:42 +020031" Show @@@ in the last line if it is truncated.
32set display=truncate
33
Bram Moolenaar4427db92016-08-28 14:39:44 +020034" Show a few lines of context around the cursor.
35set scrolloff=5
36
Bram Moolenaar8c08b5b2016-07-28 22:24:15 +020037" Do incremental searching when it's possible to timeout.
38if has('reltime')
39 set incsearch
40endif
41
42" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
43" confusing.
44set nrformats-=octal
45
46" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
47if has('win32')
48 set guioptions-=t
49endif
50
51" Don't use Ex mode, use Q for formatting.
52" Revert with ":unmap Q".
53map Q gq
54
55" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
56" so that you can undo CTRL-U after inserting a line break.
57" Revert with ":iunmap <C-U>".
58inoremap <C-U> <C-G>u<C-U>
59
60" In many terminal emulators the mouse works just fine. By enabling it you
61" can position the cursor, Visually select and scroll with the mouse.
62if has('mouse')
63 set mouse=a
64endif
65
66" Switch syntax highlighting on when the terminal has colors or when using the
67" GUI (which always has colors).
68if &t_Co > 2 || has("gui_running")
69 " Revert with ":syntax off".
70 syntax on
71
72 " I like highlighting strings inside C comments.
73 " Revert with ":unlet c_comment_strings".
74 let c_comment_strings=1
75endif
76
77" Only do this part when compiled with support for autocommands.
78if has("autocmd")
79
80 " Enable file type detection.
81 " Use the default filetype settings, so that mail gets 'tw' set to 72,
82 " 'cindent' is on in C files, etc.
83 " Also load indent files, to automatically do language-dependent indenting.
84 " Revert with ":filetype off".
85 filetype plugin indent on
86
87 " Put these in an autocmd group, so that you can revert them with:
88 " ":augroup vimStartup | au! | augroup END"
89 augroup vimStartup
90 au!
91
92 " When editing a file, always jump to the last known cursor position.
93 " Don't do it when the position is invalid or when inside an event handler
94 " (happens when dropping a file on gvim).
95 autocmd BufReadPost *
96 \ if line("'\"") >= 1 && line("'\"") <= line("$") |
97 \ exe "normal! g`\"" |
98 \ endif
99
100 augroup END
101
102endif " has("autocmd")
103
104" Convenient command to see the difference between the current buffer and the
105" file it was loaded from, thus the changes you made.
106" Only define it when not defined already.
107" Revert with: ":delcommand DiffOrig".
108if !exists(":DiffOrig")
109 command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
110 \ | wincmd p | diffthis
111endif
112
Bram Moolenaar920694c2016-08-21 17:45:02 +0200113if has('langmap') && exists('+langremap')
Bram Moolenaar8c08b5b2016-07-28 22:24:15 +0200114 " Prevent that the langmap option applies to characters that result from a
Bram Moolenaar920694c2016-08-21 17:45:02 +0200115 " mapping. If set (default), this may break plugins (but it's backward
Bram Moolenaar8c08b5b2016-07-28 22:24:15 +0200116 " compatible).
Bram Moolenaar920694c2016-08-21 17:45:02 +0200117 set nolangremap
Bram Moolenaar8c08b5b2016-07-28 22:24:15 +0200118endif