blob: b35100c1bce310cbb849cbbf1b7896f0bc4e95b0 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" An example for a vimrc file.
2"
3" Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar5c736222010-01-06 20:54:52 +01004" Last change: 2008 Dec 17
Bram Moolenaar071d4272004-06-13 20:20:40 +00005"
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.
13if v:progname =~? "evim"
14 finish
15endif
16
Bram Moolenaar5c736222010-01-06 20:54:52 +010017" Use Vim settings, rather than Vi settings (much better!).
Bram Moolenaar071d4272004-06-13 20:20:40 +000018" This must be first, because it changes other options as a side effect.
19set nocompatible
20
21" allow backspacing over everything in insert mode
22set backspace=indent,eol,start
23
24if has("vms")
25 set nobackup " do not keep a backup file, use versions instead
26else
27 set backup " keep a backup file
28endif
29set history=50 " keep 50 lines of command line history
30set ruler " show the cursor position all the time
31set showcmd " display incomplete commands
32set 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
38map Q gq
39
Bram Moolenaaraba88572008-06-25 20:13:35 +000040" 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.
42inoremap <C-U> <C-G>u<C-U>
43
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000044" In many terminal emulators the mouse works just fine, thus enable it.
Bram Moolenaarc236c162008-07-13 17:41:49 +000045if has('mouse')
46 set mouse=a
47endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000048
49" Switch syntax highlighting on, when the terminal has colors
50" Also switch on highlighting the last used search pattern.
51if &t_Co > 2 || has("gui_running")
52 syntax on
53 set hlsearch
54endif
55
56" Only do this part when compiled with support for autocommands.
57if has("autocmd")
58
59 " Enable file type detection.
60 " Use the default filetype settings, so that mail gets 'tw' set to 72,
61 " 'cindent' is on in C files, etc.
62 " Also load indent files, to automatically do language-dependent indenting.
63 filetype plugin indent on
64
65 " Put these in an autocmd group, so that we can delete them easily.
66 augroup vimrcEx
67 au!
68
69 " For all text files set 'textwidth' to 78 characters.
70 autocmd FileType text setlocal textwidth=78
71
72 " When editing a file, always jump to the last known cursor position.
73 " Don't do it when the position is invalid or when inside an event handler
74 " (happens when dropping a file on gvim).
Bram Moolenaaraba88572008-06-25 20:13:35 +000075 " Also don't do it when the mark is in the first line, that is the default
76 " position when opening a file.
Bram Moolenaar071d4272004-06-13 20:20:40 +000077 autocmd BufReadPost *
Bram Moolenaaraba88572008-06-25 20:13:35 +000078 \ if line("'\"") > 1 && line("'\"") <= line("$") |
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000079 \ exe "normal! g`\"" |
Bram Moolenaar071d4272004-06-13 20:20:40 +000080 \ endif
81
82 augroup END
83
84else
85
86 set autoindent " always set autoindenting on
87
88endif " has("autocmd")
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000089
90" Convenient command to see the difference between the current buffer and the
91" file it was loaded from, thus the changes you made.
Bram Moolenaaraba88572008-06-25 20:13:35 +000092" Only define it when not defined already.
93if !exists(":DiffOrig")
94 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
95 \ | wincmd p | diffthis
96endif