Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " An example for a vimrc file. |
| 2 | " |
| 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | 5a5f459 | 2015-04-13 12:43:06 +0200 | [diff] [blame] | 4 | " Last change: 2015 Mar 24 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | " |
| 6 | " To use it, copy it to |
| 7 | " for Unix and OS/2: ~/.vimrc |
| 8 | " for Amiga: s:.vimrc |
| 9 | " for MS-DOS and Win32: $VIM\_vimrc |
| 10 | " for OpenVMS: sys$login:.vimrc |
| 11 | |
| 12 | " When started as "evim", evim.vim will already have done these settings. |
| 13 | if v:progname =~? "evim" |
| 14 | finish |
| 15 | endif |
| 16 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 17 | " Use Vim settings, rather than Vi settings (much better!). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 18 | " This must be first, because it changes other options as a side effect. |
| 19 | set nocompatible |
| 20 | |
| 21 | " allow backspacing over everything in insert mode |
| 22 | set backspace=indent,eol,start |
| 23 | |
| 24 | if has("vms") |
| 25 | set nobackup " do not keep a backup file, use versions instead |
| 26 | else |
Bram Moolenaar | 7675688 | 2014-02-05 22:02:01 +0100 | [diff] [blame] | 27 | set backup " keep a backup file (restore to previous version) |
| 28 | set undofile " keep an undo file (undo changes after closing) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 29 | endif |
| 30 | set history=50 " keep 50 lines of command line history |
| 31 | set ruler " show the cursor position all the time |
| 32 | set showcmd " display incomplete commands |
| 33 | set incsearch " do incremental searching |
| 34 | |
| 35 | " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries |
| 36 | " let &guioptions = substitute(&guioptions, "t", "", "g") |
| 37 | |
| 38 | " Don't use Ex mode, use Q for formatting |
| 39 | map Q gq |
| 40 | |
Bram Moolenaar | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 41 | " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, |
| 42 | " so that you can undo CTRL-U after inserting a line break. |
| 43 | inoremap <C-U> <C-G>u<C-U> |
| 44 | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 45 | " In many terminal emulators the mouse works just fine, thus enable it. |
Bram Moolenaar | c236c16 | 2008-07-13 17:41:49 +0000 | [diff] [blame] | 46 | if has('mouse') |
| 47 | set mouse=a |
| 48 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 49 | |
| 50 | " Switch syntax highlighting on, when the terminal has colors |
| 51 | " Also switch on highlighting the last used search pattern. |
| 52 | if &t_Co > 2 || has("gui_running") |
| 53 | syntax on |
| 54 | set hlsearch |
| 55 | endif |
| 56 | |
| 57 | " Only do this part when compiled with support for autocommands. |
| 58 | if has("autocmd") |
| 59 | |
| 60 | " Enable file type detection. |
| 61 | " Use the default filetype settings, so that mail gets 'tw' set to 72, |
| 62 | " 'cindent' is on in C files, etc. |
| 63 | " Also load indent files, to automatically do language-dependent indenting. |
| 64 | filetype plugin indent on |
| 65 | |
| 66 | " Put these in an autocmd group, so that we can delete them easily. |
| 67 | augroup vimrcEx |
| 68 | au! |
| 69 | |
| 70 | " For all text files set 'textwidth' to 78 characters. |
| 71 | autocmd FileType text setlocal textwidth=78 |
| 72 | |
| 73 | " When editing a file, always jump to the last known cursor position. |
| 74 | " Don't do it when the position is invalid or when inside an event handler |
| 75 | " (happens when dropping a file on gvim). |
| 76 | autocmd BufReadPost * |
Bram Moolenaar | 5a5f459 | 2015-04-13 12:43:06 +0200 | [diff] [blame] | 77 | \ if line("'\"") >= 1 && line("'\"") <= line("$") | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 78 | \ exe "normal! g`\"" | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 79 | \ endif |
| 80 | |
| 81 | augroup END |
| 82 | |
| 83 | else |
| 84 | |
| 85 | set autoindent " always set autoindenting on |
| 86 | |
| 87 | endif " has("autocmd") |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 88 | |
| 89 | " Convenient command to see the difference between the current buffer and the |
| 90 | " file it was loaded from, thus the changes you made. |
Bram Moolenaar | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 91 | " Only define it when not defined already. |
| 92 | if !exists(":DiffOrig") |
Bram Moolenaar | 8e5af3e | 2011-04-28 19:02:44 +0200 | [diff] [blame] | 93 | command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis |
Bram Moolenaar | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 94 | \ | wincmd p | diffthis |
| 95 | endif |
Bram Moolenaar | 4391cf9 | 2014-11-05 17:44:52 +0100 | [diff] [blame] | 96 | |
| 97 | if has('langmap') && exists('+langnoremap') |
| 98 | " Prevent that the langmap option applies to characters that result from a |
| 99 | " mapping. If unset (default), this may break plugins (but it's backward |
| 100 | " compatible). |
| 101 | set langnoremap |
| 102 | endif |