1" The default vimrc file. 2" 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last change: 2020 Sep 30 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" 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 22" Use Vim settings, rather than Vi settings (much better!). 23" This must be first, because it changes other options as a side effect. 24" Avoid side effects when it was already reset. 25if &compatible 26 set nocompatible 27endif 28 29" When the +eval feature is missing, the set command above will be skipped. 30" Use a trick to reset compatible only when the +eval feature is missing. 31silent! while 0 32 set nocompatible 33silent! endwhile 34 35" Allow backspacing over everything in insert mode. 36set backspace=indent,eol,start 37 38set history=200 " keep 200 lines of command line history 39set ruler " show the cursor position all the time 40set showcmd " display incomplete commands 41set wildmenu " display completion matches in a status line 42 43set ttimeout " time out for key codes 44set ttimeoutlen=100 " wait up to 100ms after Esc for special key 45 46" Show @@@ in the last line if it is truncated. 47set display=truncate 48 49" Show a few lines of context around the cursor. Note that this makes the 50" text scroll if you mouse-click near the start or end of the window. 51set scrolloff=5 52 53" Do incremental searching when it's possible to timeout. 54if has('reltime') 55 set incsearch 56endif 57 58" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it 59" confusing. 60set nrformats-=octal 61 62" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries. 63if has('win32') 64 set guioptions-=t 65endif 66 67" Don't use Ex mode, use Q for formatting. 68" Revert with ":unmap Q". 69map Q gq 70 71" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, 72" so that you can undo CTRL-U after inserting a line break. 73" Revert with ":iunmap <C-U>". 74inoremap <C-U> <C-G>u<C-U> 75 76" In many terminal emulators the mouse works just fine. By enabling it you 77" can position the cursor, Visually select and scroll with the mouse. 78" Only xterm can grab the mouse events when using the shift key, for other 79" terminals use ":", select text and press Esc. 80if has('mouse') 81 if &term =~ 'xterm' 82 set mouse=a 83 else 84 set mouse=nvi 85 endif 86endif 87 88" Only do this part when Vim was compiled with the +eval feature. 89if 1 90 91 " Enable file type detection. 92 " Use the default filetype settings, so that mail gets 'tw' set to 72, 93 " 'cindent' is on in C files, etc. 94 " Also load indent files, to automatically do language-dependent indenting. 95 " Revert with ":filetype off". 96 filetype plugin indent on 97 98 " Put these in an autocmd group, so that you can revert them with: 99 " ":augroup vimStartup | au! | augroup END" 100 augroup vimStartup 101 au! 102 103 " When editing a file, always jump to the last known cursor position. 104 " Don't do it when the position is invalid, when inside an event handler 105 " (happens when dropping a file on gvim) and for a commit message (it's 106 " likely a different one than last time). 107 autocmd BufReadPost * 108 \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' 109 \ | exe "normal! g`\"" 110 \ | endif 111 112 augroup END 113 114 " Quite a few people accidentally type "q:" instead of ":q" and get confused 115 " by the command line window. Give a hint about how to get out. 116 " If you don't like this you can put this in your vimrc: 117 " ":augroup vimHints | au! | augroup END" 118 augroup vimHints 119 autocmd! CmdwinEnter * 120 \ echohl Todo | 121 \ echo 'You discovered the command-line window! You can close it with ":q".' | 122 \ echohl None 123 augroup END 124 125endif 126 127" Switch syntax highlighting on when the terminal has colors or when using the 128" GUI (which always has colors). 129if &t_Co > 2 || has("gui_running") 130 " Revert with ":syntax off". 131 syntax on 132 133 " I like highlighting strings inside C comments. 134 " Revert with ":unlet c_comment_strings". 135 let c_comment_strings=1 136endif 137 138" Convenient command to see the difference between the current buffer and the 139" file it was loaded from, thus the changes you made. 140" Only define it when not defined already. 141" Revert with: ":delcommand DiffOrig". 142if !exists(":DiffOrig") 143 command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis 144 \ | wincmd p | diffthis 145endif 146 147if has('langmap') && exists('+langremap') 148 " Prevent that the langmap option applies to characters that result from a 149 " mapping. If set (default), this may break plugins (but it's backward 150 " compatible). 151 set nolangremap 152endif 153