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