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