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