defaults.vim (5342B)
1 " The default vimrc file. 2 " 3 " Maintainer: The Vim Project <https://github.com/vim/vim> 4 " Last Change: 2025 Nov 28 5 " Former Maintainer: Bram Moolenaar <Bram@vim.org> 6 " 7 " This is loaded if no vimrc file was found. 8 " Except when Vim is run with "-u NONE" or "-C". 9 " Individual settings can be reverted with ":set option&". 10 " Other commands can be reverted as mentioned below. 11 12 " When started as "evim", evim.vim will already have done these settings. 13 if v:progname =~? "evim" 14 finish 15 endif 16 17 " Bail out if something that ran earlier, e.g. a system wide vimrc, does not 18 " want Vim to use these default values. 19 if exists('skip_defaults_vim') 20 finish 21 endif 22 23 " Use Vim settings, rather than Vi settings (much better!). 24 " This must be first, because it changes other options as a side effect. 25 " Avoid side effects when it was already reset. 26 if &compatible 27 set nocompatible 28 endif 29 30 " When the +eval feature is missing, the set command above will be skipped. 31 " Use a trick to reset compatible only when the +eval feature is missing. 32 silent! while 0 33 set nocompatible 34 silent! endwhile 35 36 set ttimeout " time out for key codes 37 set ttimeoutlen=100 " wait up to 100ms after Esc for special key 38 39 " Show @@@ in the last line if it is truncated. 40 set display=truncate 41 42 " Show a few lines of context around the cursor. Note that this makes the 43 " text scroll if you mouse-click near the start or end of the window. 44 set scrolloff=5 45 46 " Do incremental searching when it's possible to timeout. 47 if has('reltime') 48 set incsearch 49 endif 50 51 " Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it 52 " confusing. 53 set nrformats-=octal 54 55 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries. 56 if has('win32') 57 set guioptions-=t 58 endif 59 60 " Don't use Q for Ex mode, use it for formatting. Except for Select mode. 61 " Revert with ":unmap Q". 62 map Q gq 63 sunmap Q 64 65 " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, 66 " so that you can undo CTRL-U after inserting a line break. 67 " Revert with ":iunmap <C-U>". 68 inoremap <C-U> <C-G>u<C-U> 69 70 " In many terminal emulators the mouse works just fine. By enabling it you 71 " can position the cursor, Visually select and scroll with the mouse. 72 " Only xterm can grab the mouse events when using the shift key, for other 73 " terminals use ":", select text and press Esc. 74 if has('mouse') 75 if &term =~ 'xterm' 76 set mouse=a 77 else 78 set mouse=nvi 79 endif 80 endif 81 82 " Only do this part when Vim was compiled with the +eval feature. 83 if 1 84 85 " Enable file type detection. 86 " Use the default filetype settings, so that mail gets 'tw' set to 72, 87 " 'cindent' is on in C files, etc. 88 " Also load indent files, to automatically do language-dependent indenting. 89 " Revert with ":filetype off". 90 filetype plugin indent on 91 92 " Put these in an autocmd group, so that you can revert them with: 93 " ":autocmd! vimStartup" 94 augroup vimStartup 95 autocmd! 96 97 " When editing a file, always jump to the last known cursor position. 98 " Don't do it when the position is invalid, when inside an event handler 99 " (happens when dropping a file on gvim), for a commit or rebase message 100 " (likely a different one than last time), and when using xxd(1) to filter 101 " and edit binary files (it transforms input files back and forth, causing 102 " them to have dual nature, so to speak) or when running the new tutor 103 autocmd BufReadPost * 104 \ let line = line("'\"") 105 \ | if line >= 1 && line <= line("$") && &filetype !~# 'commit' 106 \ && index(['xxd', 'gitrebase', 'tutor'], &filetype) == -1 107 \ && !&diff 108 \ | execute "normal! g`\"" 109 \ | endif 110 111 " Set the default background for putty to dark. Putty usually sets the 112 " $TERM to xterm and by default it starts with a dark background which 113 " makes syntax highlighting often hard to read with bg=light 114 " undo this using: ":au! vimStartup TermResponse" 115 autocmd TermResponse * if v:termresponse == "\e[>0;136;0c" | set bg=dark | endif 116 augroup END 117 118 " Quite a few people accidentally type "q:" instead of ":q" and get confused 119 " by the command line window. Give a hint about how to get out. 120 " If you don't like this you can put this in your vimrc: 121 " ":autocmd! vimHints" 122 augroup vimHints 123 au! 124 autocmd CmdwinEnter * 125 \ echohl Todo | 126 \ echo gettext('You discovered the command-line window! You can close it with ":q".') | 127 \ echohl None 128 augroup END 129 130 endif 131 132 " Switch syntax highlighting on when the terminal has colors or when using the 133 " GUI (which always has colors). 134 if &t_Co > 2 || has("gui_running") 135 " Revert with ":syntax off". 136 syntax on 137 138 " I like highlighting strings inside C comments. 139 " Revert with ":unlet g:c_comment_strings". 140 let c_comment_strings=1 141 endif 142 143 " Convenient command to see the difference between the current buffer and the 144 " file it was loaded from, thus the changes you made. 145 " Only define it when not defined already. 146 " Revert with: ":delcommand DiffOrig". 147 if !exists(":DiffOrig") 148 command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis 149 \ | wincmd p | diffthis 150 endif 151 152 if has('langmap') && exists('+langremap') 153 " Prevent that the langmap option applies to characters that result from a 154 " mapping. If set (default), this may break plugins (but it's backward 155 " compatible). 156 set nolangremap 157 endif