Bram Moolenaar | 8c08b5b | 2016-07-28 22:24:15 +0200 | [diff] [blame] | 1 | " The default vimrc file. |
| 2 | " |
| 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | b07a82b | 2016-09-03 20:08:56 +0200 | [diff] [blame] | 4 | " Last change: 2016 Sep 02 |
Bram Moolenaar | 8c08b5b | 2016-07-28 22:24:15 +0200 | [diff] [blame] | 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. |
| 12 | if v:progname =~? "evim" |
| 13 | finish |
| 14 | endif |
| 15 | |
Bram Moolenaar | b07a82b | 2016-09-03 20:08:56 +0200 | [diff] [blame] | 16 | " Bail out if something that ran earlier, e.g. a system wide vimrc, does not |
| 17 | " want Vim to use these default values. |
| 18 | if exists('skip_defaults_vim') |
| 19 | finish |
| 20 | endif |
| 21 | |
Bram Moolenaar | 8c08b5b | 2016-07-28 22:24:15 +0200 | [diff] [blame] | 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 | set nocompatible |
| 25 | |
| 26 | " Allow backspacing over everything in insert mode. |
| 27 | set backspace=indent,eol,start |
| 28 | |
| 29 | set history=200 " keep 200 lines of command line history |
| 30 | set ruler " show the cursor position all the time |
| 31 | set showcmd " display incomplete commands |
| 32 | set wildmenu " display completion matches in a status line |
| 33 | |
Bram Moolenaar | e07e797 | 2016-08-20 19:22:16 +0200 | [diff] [blame] | 34 | set ttimeout " time out for key codes |
| 35 | set ttimeoutlen=100 " wait up to 100ms after Esc for special key |
| 36 | |
Bram Moolenaar | b9a46fe | 2016-07-29 18:13:42 +0200 | [diff] [blame] | 37 | " Show @@@ in the last line if it is truncated. |
| 38 | set display=truncate |
| 39 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 40 | " Show a few lines of context around the cursor. Note that this makes the |
| 41 | " text scroll if you mouse-click near the start or end of the window. |
Bram Moolenaar | 4427db9 | 2016-08-28 14:39:44 +0200 | [diff] [blame] | 42 | set scrolloff=5 |
| 43 | |
Bram Moolenaar | 8c08b5b | 2016-07-28 22:24:15 +0200 | [diff] [blame] | 44 | " Do incremental searching when it's possible to timeout. |
| 45 | if has('reltime') |
| 46 | set incsearch |
| 47 | endif |
| 48 | |
| 49 | " Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it |
| 50 | " confusing. |
| 51 | set nrformats-=octal |
| 52 | |
| 53 | " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries. |
| 54 | if has('win32') |
| 55 | set guioptions-=t |
| 56 | endif |
| 57 | |
| 58 | " Don't use Ex mode, use Q for formatting. |
| 59 | " Revert with ":unmap Q". |
| 60 | map Q gq |
| 61 | |
| 62 | " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, |
| 63 | " so that you can undo CTRL-U after inserting a line break. |
| 64 | " Revert with ":iunmap <C-U>". |
| 65 | inoremap <C-U> <C-G>u<C-U> |
| 66 | |
| 67 | " In many terminal emulators the mouse works just fine. By enabling it you |
| 68 | " can position the cursor, Visually select and scroll with the mouse. |
| 69 | if has('mouse') |
| 70 | set mouse=a |
| 71 | endif |
| 72 | |
| 73 | " Switch syntax highlighting on when the terminal has colors or when using the |
| 74 | " GUI (which always has colors). |
| 75 | if &t_Co > 2 || has("gui_running") |
| 76 | " Revert with ":syntax off". |
| 77 | syntax on |
| 78 | |
| 79 | " I like highlighting strings inside C comments. |
| 80 | " Revert with ":unlet c_comment_strings". |
| 81 | let c_comment_strings=1 |
| 82 | endif |
| 83 | |
| 84 | " Only do this part when compiled with support for autocommands. |
| 85 | if has("autocmd") |
| 86 | |
| 87 | " Enable file type detection. |
| 88 | " Use the default filetype settings, so that mail gets 'tw' set to 72, |
| 89 | " 'cindent' is on in C files, etc. |
| 90 | " Also load indent files, to automatically do language-dependent indenting. |
| 91 | " Revert with ":filetype off". |
| 92 | filetype plugin indent on |
| 93 | |
| 94 | " Put these in an autocmd group, so that you can revert them with: |
| 95 | " ":augroup vimStartup | au! | augroup END" |
| 96 | augroup vimStartup |
| 97 | au! |
| 98 | |
| 99 | " When editing a file, always jump to the last known cursor position. |
| 100 | " Don't do it when the position is invalid or when inside an event handler |
| 101 | " (happens when dropping a file on gvim). |
| 102 | autocmd BufReadPost * |
| 103 | \ if line("'\"") >= 1 && line("'\"") <= line("$") | |
| 104 | \ exe "normal! g`\"" | |
| 105 | \ endif |
| 106 | |
| 107 | augroup END |
| 108 | |
| 109 | endif " has("autocmd") |
| 110 | |
| 111 | " Convenient command to see the difference between the current buffer and the |
| 112 | " file it was loaded from, thus the changes you made. |
| 113 | " Only define it when not defined already. |
| 114 | " Revert with: ":delcommand DiffOrig". |
| 115 | if !exists(":DiffOrig") |
| 116 | command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis |
| 117 | \ | wincmd p | diffthis |
| 118 | endif |
| 119 | |
Bram Moolenaar | 920694c | 2016-08-21 17:45:02 +0200 | [diff] [blame] | 120 | if has('langmap') && exists('+langremap') |
Bram Moolenaar | 8c08b5b | 2016-07-28 22:24:15 +0200 | [diff] [blame] | 121 | " Prevent that the langmap option applies to characters that result from a |
Bram Moolenaar | 920694c | 2016-08-21 17:45:02 +0200 | [diff] [blame] | 122 | " mapping. If set (default), this may break plugins (but it's backward |
Bram Moolenaar | 8c08b5b | 2016-07-28 22:24:15 +0200 | [diff] [blame] | 123 | " compatible). |
Bram Moolenaar | 920694c | 2016-08-21 17:45:02 +0200 | [diff] [blame] | 124 | set nolangremap |
Bram Moolenaar | 8c08b5b | 2016-07-28 22:24:15 +0200 | [diff] [blame] | 125 | endif |