annotate runtime/vimrc_example.vim @ 9481:7520696c14b0 v7.4.2021

commit https://github.com/vim/vim/commit/19ff9bf454b7492be64dd87aaf0830fa7961871e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 10 19:03:57 2016 +0200 patch 7.4.2021 Problem: Still too many buf_valid() calls. Solution: Make au_new_curbuf a bufref. Use bufref_valid() in more places.
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Jul 2016 19:15:06 +0200
parents 33c1b85d408c
children 284b4eb307fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " An example for a vimrc file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
9344
33c1b85d408c commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents: 8853
diff changeset
4 " Last change: 2016 Jun 21
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " To use it, copy it to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " for Unix and OS/2: ~/.vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " for Amiga: s:.vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " for MS-DOS and Win32: $VIM\_vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " for OpenVMS: sys$login:.vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " When started as "evim", evim.vim will already have done these settings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 if v:progname =~? "evim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
17 " Use Vim settings, rather than Vi settings (much better!).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 " This must be first, because it changes other options as a side effect.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 set nocompatible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 " allow backspacing over everything in insert mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 set backspace=indent,eol,start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 if has("vms")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 set nobackup " do not keep a backup file, use versions instead
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 else
5637
c82339d8fdae updated for version 7.4.165
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
27 set backup " keep a backup file (restore to previous version)
c82339d8fdae updated for version 7.4.165
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
28 set undofile " keep an undo file (undo changes after closing)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 set history=50 " keep 50 lines of command line history
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 set ruler " show the cursor position all the time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 set showcmd " display incomplete commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 set incsearch " do incremental searching
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " let &guioptions = substitute(&guioptions, "t", "", "g")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " Don't use Ex mode, use Q for formatting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 map Q gq
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
1648
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
41 " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
42 " so that you can undo CTRL-U after inserting a line break.
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
43 inoremap <C-U> <C-G>u<C-U>
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
44
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 7
diff changeset
45 " In many terminal emulators the mouse works just fine, thus enable it.
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1648
diff changeset
46 if has('mouse')
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1648
diff changeset
47 set mouse=a
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1648
diff changeset
48 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
8853
48b4c1c284fb commit https://github.com/vim/vim/commit/54f1b7abf8c48b1dd997202258d1d0673ed4bd29
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
50 " Switch syntax highlighting on when the terminal has colors or when using the
48b4c1c284fb commit https://github.com/vim/vim/commit/54f1b7abf8c48b1dd997202258d1d0673ed4bd29
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
51 " GUI (which always has colors).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 if &t_Co > 2 || has("gui_running")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 syntax on
8853
48b4c1c284fb commit https://github.com/vim/vim/commit/54f1b7abf8c48b1dd997202258d1d0673ed4bd29
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
54
48b4c1c284fb commit https://github.com/vim/vim/commit/54f1b7abf8c48b1dd997202258d1d0673ed4bd29
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
55 " Also switch on highlighting the last used search pattern.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 set hlsearch
8853
48b4c1c284fb commit https://github.com/vim/vim/commit/54f1b7abf8c48b1dd997202258d1d0673ed4bd29
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
57
48b4c1c284fb commit https://github.com/vim/vim/commit/54f1b7abf8c48b1dd997202258d1d0673ed4bd29
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
58 " I like highlighting strings inside C comments.
48b4c1c284fb commit https://github.com/vim/vim/commit/54f1b7abf8c48b1dd997202258d1d0673ed4bd29
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
59 let c_comment_strings=1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 " Only do this part when compiled with support for autocommands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 if has("autocmd")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " Enable file type detection.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " Use the default filetype settings, so that mail gets 'tw' set to 72,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 " 'cindent' is on in C files, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " Also load indent files, to automatically do language-dependent indenting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 filetype plugin indent on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 " Put these in an autocmd group, so that we can delete them easily.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 augroup vimrcEx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 au!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " For all text files set 'textwidth' to 78 characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 autocmd FileType text setlocal textwidth=78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " When editing a file, always jump to the last known cursor position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 " Don't do it when the position is invalid or when inside an event handler
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 " (happens when dropping a file on gvim).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 autocmd BufReadPost *
6741
fbc1131f0ba5 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6339
diff changeset
82 \ if line("'\"") >= 1 && line("'\"") <= line("$") |
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 7
diff changeset
83 \ exe "normal! g`\"" |
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 \ endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 augroup END
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 set autoindent " always set autoindenting on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 endif " has("autocmd")
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 7
diff changeset
93
96cd8222a819 updated for version 7.1a
vimboss
parents: 7
diff changeset
94 " Convenient command to see the difference between the current buffer and the
96cd8222a819 updated for version 7.1a
vimboss
parents: 7
diff changeset
95 " file it was loaded from, thus the changes you made.
1648
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
96 " Only define it when not defined already.
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
97 if !exists(":DiffOrig")
2788
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
98 command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
1648
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
99 \ | wincmd p | diffthis
58cad056e608 updated for version 7.2a-00
vimboss
parents: 1125
diff changeset
100 endif
6339
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5637
diff changeset
101
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5637
diff changeset
102 if has('langmap') && exists('+langnoremap')
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5637
diff changeset
103 " Prevent that the langmap option applies to characters that result from a
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5637
diff changeset
104 " mapping. If unset (default), this may break plugins (but it's backward
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5637
diff changeset
105 " compatible).
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5637
diff changeset
106 set langnoremap
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5637
diff changeset
107 endif
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 6741
diff changeset
108
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 6741
diff changeset
109
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 6741
diff changeset
110 " Add optional packages.
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 6741
diff changeset
111 "
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 6741
diff changeset
112 " The matchit plugin makes the % command work better, but it is not backwards
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 6741
diff changeset
113 " compatible.
9344
33c1b85d408c commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents: 8853
diff changeset
114 if has('syntax') && has('eval')
33c1b85d408c commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents: 8853
diff changeset
115 packadd matchit
33c1b85d408c commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents: 8853
diff changeset
116 endif