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