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 | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 4 | " Last change: 2008 Jun 16 |
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 | |
| 17 | " Use Vim settings, rather then Vi settings (much better!). |
| 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 |
| 27 | set backup " keep a backup file |
| 28 | endif |
| 29 | set history=50 " keep 50 lines of command line history |
| 30 | set ruler " show the cursor position all the time |
| 31 | set showcmd " display incomplete commands |
| 32 | set incsearch " do incremental searching |
| 33 | |
| 34 | " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries |
| 35 | " let &guioptions = substitute(&guioptions, "t", "", "g") |
| 36 | |
| 37 | " Don't use Ex mode, use Q for formatting |
| 38 | map Q gq |
| 39 | |
Bram Moolenaar | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 40 | " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, |
| 41 | " so that you can undo CTRL-U after inserting a line break. |
| 42 | inoremap <C-U> <C-G>u<C-U> |
| 43 | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 44 | " In many terminal emulators the mouse works just fine, thus enable it. |
| 45 | set mouse=a |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 46 | |
| 47 | " Switch syntax highlighting on, when the terminal has colors |
| 48 | " Also switch on highlighting the last used search pattern. |
| 49 | if &t_Co > 2 || has("gui_running") |
| 50 | syntax on |
| 51 | set hlsearch |
| 52 | endif |
| 53 | |
| 54 | " Only do this part when compiled with support for autocommands. |
| 55 | if has("autocmd") |
| 56 | |
| 57 | " Enable file type detection. |
| 58 | " Use the default filetype settings, so that mail gets 'tw' set to 72, |
| 59 | " 'cindent' is on in C files, etc. |
| 60 | " Also load indent files, to automatically do language-dependent indenting. |
| 61 | filetype plugin indent on |
| 62 | |
| 63 | " Put these in an autocmd group, so that we can delete them easily. |
| 64 | augroup vimrcEx |
| 65 | au! |
| 66 | |
| 67 | " For all text files set 'textwidth' to 78 characters. |
| 68 | autocmd FileType text setlocal textwidth=78 |
| 69 | |
| 70 | " When editing a file, always jump to the last known cursor position. |
| 71 | " Don't do it when the position is invalid or when inside an event handler |
| 72 | " (happens when dropping a file on gvim). |
Bram Moolenaar | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 73 | " Also don't do it when the mark is in the first line, that is the default |
| 74 | " position when opening a file. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 75 | autocmd BufReadPost * |
Bram Moolenaar | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 76 | \ if line("'\"") > 1 && line("'\"") <= line("$") | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 77 | \ exe "normal! g`\"" | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 78 | \ endif |
| 79 | |
| 80 | augroup END |
| 81 | |
| 82 | else |
| 83 | |
| 84 | set autoindent " always set autoindenting on |
| 85 | |
| 86 | endif " has("autocmd") |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 87 | |
| 88 | " Convenient command to see the difference between the current buffer and the |
| 89 | " file it was loaded from, thus the changes you made. |
Bram Moolenaar | aba8857 | 2008-06-25 20:13:35 +0000 | [diff] [blame] | 90 | " Only define it when not defined already. |
| 91 | if !exists(":DiffOrig") |
| 92 | command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis |
| 93 | \ | wincmd p | diffthis |
| 94 | endif |