xref: /vim-8.2.3635/runtime/defaults.vim (revision 125ffd21)
18c08b5b5SBram Moolenaar" The default vimrc file.
28c08b5b5SBram Moolenaar"
38c08b5b5SBram Moolenaar" Maintainer:	Bram Moolenaar <[email protected]>
44f4d51a9SBram Moolenaar" Last change:	2020 Sep 30
58c08b5b5SBram Moolenaar"
68c08b5b5SBram Moolenaar" This is loaded if no vimrc file was found.
78c08b5b5SBram Moolenaar" Except when Vim is run with "-u NONE" or "-C".
88c08b5b5SBram Moolenaar" Individual settings can be reverted with ":set option&".
98c08b5b5SBram Moolenaar" Other commands can be reverted as mentioned below.
108c08b5b5SBram Moolenaar
118c08b5b5SBram Moolenaar" When started as "evim", evim.vim will already have done these settings.
128c08b5b5SBram Moolenaarif v:progname =~? "evim"
138c08b5b5SBram Moolenaar  finish
148c08b5b5SBram Moolenaarendif
158c08b5b5SBram Moolenaar
16b07a82b6SBram Moolenaar" Bail out if something that ran earlier, e.g. a system wide vimrc, does not
17b07a82b6SBram Moolenaar" want Vim to use these default values.
18b07a82b6SBram Moolenaarif exists('skip_defaults_vim')
19b07a82b6SBram Moolenaar  finish
20b07a82b6SBram Moolenaarendif
21b07a82b6SBram Moolenaar
228c08b5b5SBram Moolenaar" Use Vim settings, rather than Vi settings (much better!).
238c08b5b5SBram Moolenaar" This must be first, because it changes other options as a side effect.
240f39a82bSBram Moolenaar" Avoid side effects when it was already reset.
250f39a82bSBram Moolenaarif &compatible
268c08b5b5SBram Moolenaar  set nocompatible
270f39a82bSBram Moolenaarendif
288c08b5b5SBram Moolenaar
2933ccb24cSBram Moolenaar" When the +eval feature is missing, the set command above will be skipped.
3033ccb24cSBram Moolenaar" Use a trick to reset compatible only when the +eval feature is missing.
3143d1ac6eSBram Moolenaarsilent! while 0
3243d1ac6eSBram Moolenaar  set nocompatible
3343d1ac6eSBram Moolenaarsilent! endwhile
3433ccb24cSBram Moolenaar
358c08b5b5SBram Moolenaar" Allow backspacing over everything in insert mode.
368c08b5b5SBram Moolenaarset backspace=indent,eol,start
378c08b5b5SBram Moolenaar
388c08b5b5SBram Moolenaarset history=200		" keep 200 lines of command line history
398c08b5b5SBram Moolenaarset ruler		" show the cursor position all the time
408c08b5b5SBram Moolenaarset showcmd		" display incomplete commands
418c08b5b5SBram Moolenaarset wildmenu		" display completion matches in a status line
428c08b5b5SBram Moolenaar
43e07e797dSBram Moolenaarset ttimeout		" time out for key codes
44e07e797dSBram Moolenaarset ttimeoutlen=100	" wait up to 100ms after Esc for special key
45e07e797dSBram Moolenaar
46b9a46fecSBram Moolenaar" Show @@@ in the last line if it is truncated.
47b9a46fecSBram Moolenaarset display=truncate
48b9a46fecSBram Moolenaar
4989bcfda6SBram Moolenaar" Show a few lines of context around the cursor.  Note that this makes the
5089bcfda6SBram Moolenaar" text scroll if you mouse-click near the start or end of the window.
514427db9bSBram Moolenaarset scrolloff=5
524427db9bSBram Moolenaar
538c08b5b5SBram Moolenaar" Do incremental searching when it's possible to timeout.
548c08b5b5SBram Moolenaarif has('reltime')
558c08b5b5SBram Moolenaar  set incsearch
568c08b5b5SBram Moolenaarendif
578c08b5b5SBram Moolenaar
588c08b5b5SBram Moolenaar" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
598c08b5b5SBram Moolenaar" confusing.
608c08b5b5SBram Moolenaarset nrformats-=octal
618c08b5b5SBram Moolenaar
628c08b5b5SBram Moolenaar" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
638c08b5b5SBram Moolenaarif has('win32')
648c08b5b5SBram Moolenaar  set guioptions-=t
658c08b5b5SBram Moolenaarendif
668c08b5b5SBram Moolenaar
678c08b5b5SBram Moolenaar" Don't use Ex mode, use Q for formatting.
688c08b5b5SBram Moolenaar" Revert with ":unmap Q".
698c08b5b5SBram Moolenaarmap Q gq
708c08b5b5SBram Moolenaar
718c08b5b5SBram Moolenaar" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
728c08b5b5SBram Moolenaar" so that you can undo CTRL-U after inserting a line break.
738c08b5b5SBram Moolenaar" Revert with ":iunmap <C-U>".
748c08b5b5SBram Moolenaarinoremap <C-U> <C-G>u<C-U>
758c08b5b5SBram Moolenaar
768c08b5b5SBram Moolenaar" In many terminal emulators the mouse works just fine.  By enabling it you
778c08b5b5SBram Moolenaar" can position the cursor, Visually select and scroll with the mouse.
785b418992SBram Moolenaar" Only xterm can grab the mouse events when using the shift key, for other
795b418992SBram Moolenaar" terminals use ":", select text and press Esc.
808c08b5b5SBram Moolenaarif has('mouse')
815b418992SBram Moolenaar  if &term =~ 'xterm'
828c08b5b5SBram Moolenaar    set mouse=a
835b418992SBram Moolenaar  else
845b418992SBram Moolenaar    set mouse=nvi
855b418992SBram Moolenaar  endif
868c08b5b5SBram Moolenaarendif
878c08b5b5SBram Moolenaar
88d53931aeSBram Moolenaar" Only do this part when Vim was compiled with the +eval feature.
89d53931aeSBram Moolenaarif 1
90d53931aeSBram Moolenaar
918c08b5b5SBram Moolenaar  " Enable file type detection.
928c08b5b5SBram Moolenaar  " Use the default filetype settings, so that mail gets 'tw' set to 72,
938c08b5b5SBram Moolenaar  " 'cindent' is on in C files, etc.
948c08b5b5SBram Moolenaar  " Also load indent files, to automatically do language-dependent indenting.
958c08b5b5SBram Moolenaar  " Revert with ":filetype off".
968c08b5b5SBram Moolenaar  filetype plugin indent on
978c08b5b5SBram Moolenaar
988c08b5b5SBram Moolenaar  " Put these in an autocmd group, so that you can revert them with:
998c08b5b5SBram Moolenaar  " ":augroup vimStartup | au! | augroup END"
1008c08b5b5SBram Moolenaar  augroup vimStartup
1018c08b5b5SBram Moolenaar    au!
1028c08b5b5SBram Moolenaar
1038c08b5b5SBram Moolenaar    " When editing a file, always jump to the last known cursor position.
1049a48961dSBram Moolenaar    " Don't do it when the position is invalid, when inside an event handler
1059a48961dSBram Moolenaar    " (happens when dropping a file on gvim) and for a commit message (it's
1069a48961dSBram Moolenaar    " likely a different one than last time).
1078c08b5b5SBram Moolenaar    autocmd BufReadPost *
1089a48961dSBram Moolenaar      \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
1099a48961dSBram Moolenaar      \ |   exe "normal! g`\""
1109a48961dSBram Moolenaar      \ | endif
1118c08b5b5SBram Moolenaar
1128c08b5b5SBram Moolenaar  augroup END
1138c08b5b5SBram Moolenaar
114*125ffd21SEgor Zvorykin  " Quite a few people accidentally type "q:" instead of ":q" and get confused
115*125ffd21SEgor Zvorykin  " by the command line window.  Give a hint about how to get out.
116*125ffd21SEgor Zvorykin  " If you don't like this you can put this in your vimrc:
117*125ffd21SEgor Zvorykin  " ":augroup vimHints | au! | augroup END"
118*125ffd21SEgor Zvorykin  augroup vimHints
119*125ffd21SEgor Zvorykin    autocmd! CmdwinEnter *
120*125ffd21SEgor Zvorykin	  \ echohl Todo |
121*125ffd21SEgor Zvorykin	  \ echo 'You discovered the command-line window! You can close it with ":q".' |
122*125ffd21SEgor Zvorykin	  \ echohl None
123*125ffd21SEgor Zvorykin  augroup END
124*125ffd21SEgor Zvorykin
125d53931aeSBram Moolenaarendif
126d53931aeSBram Moolenaar
12717bb4d46SBram Moolenaar" Switch syntax highlighting on when the terminal has colors or when using the
12817bb4d46SBram Moolenaar" GUI (which always has colors).
12917bb4d46SBram Moolenaarif &t_Co > 2 || has("gui_running")
13017bb4d46SBram Moolenaar  " Revert with ":syntax off".
13117bb4d46SBram Moolenaar  syntax on
13217bb4d46SBram Moolenaar
13317bb4d46SBram Moolenaar  " I like highlighting strings inside C comments.
13417bb4d46SBram Moolenaar  " Revert with ":unlet c_comment_strings".
13517bb4d46SBram Moolenaar  let c_comment_strings=1
13617bb4d46SBram Moolenaarendif
13717bb4d46SBram Moolenaar
1388c08b5b5SBram Moolenaar" Convenient command to see the difference between the current buffer and the
1398c08b5b5SBram Moolenaar" file it was loaded from, thus the changes you made.
1408c08b5b5SBram Moolenaar" Only define it when not defined already.
1418c08b5b5SBram Moolenaar" Revert with: ":delcommand DiffOrig".
1428c08b5b5SBram Moolenaarif !exists(":DiffOrig")
1438c08b5b5SBram Moolenaar  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
1448c08b5b5SBram Moolenaar		  \ | wincmd p | diffthis
1458c08b5b5SBram Moolenaarendif
1468c08b5b5SBram Moolenaar
147920694c1SBram Moolenaarif has('langmap') && exists('+langremap')
1488c08b5b5SBram Moolenaar  " Prevent that the langmap option applies to characters that result from a
149920694c1SBram Moolenaar  " mapping.  If set (default), this may break plugins (but it's backward
1508c08b5b5SBram Moolenaar  " compatible).
151920694c1SBram Moolenaar  set nolangremap
1528c08b5b5SBram Moolenaarendif
153