1 " An example for a vimrc file.
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last change: 2000 Oct 14
6 " To use it, copy it to
7 " for Unix and OS/2: ~/.vimrc
9 " for MS-DOS and Win32: $VIM\_vimrc
10 " for OpenVMS: sys$login:.vimrc
12 " Use Vim settings, rather then Vi settings (much better!).
13 " This must be first, because it changes other options as a side effect.
16 set bs=2 " allow backspacing over everything in insert mode
17 set ai " always set autoindenting on
19 set nobackup " do not keep a backup file, use versions instead
21 set backup " keep a backup file
23 set viminfo='20,\"50 " read/write a .viminfo file, don't store more
24 " than 50 lines of registers
25 set history=50 " keep 50 lines of command line history
26 set ruler " show the cursor position all the time
28 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
29 " let &guioptions = substitute(&guioptions, "t", "", "g")
31 " Don't use Ex mode, use Q for formatting
34 " Make p in Visual mode replace the selected text with the "" register.
35 vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
37 " Switch syntax highlighting on, when the terminal has colors
38 " Also switch on highlighting the last used search pattern.
39 if &t_Co > 2 || has("gui_running")
44 " Only do this part when compiled with support for autocommands.
47 " In text files, always limit the width of text to 78 characters
48 autocmd BufRead *.txt set tw=78
51 " Remove all cprog autocommands
54 " When starting to edit a file:
55 " For C and C++ files set formatting of comments and set C-indenting on.
56 " For other files switch it off.
57 " Don't change the order, it's important that the line with * comes first.
58 autocmd FileType * set formatoptions=tcql nocindent comments&
59 autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
63 " Remove all gzip autocommands
66 " Enable editing of gzipped files
67 " set binary mode before reading the file
68 " use "gzip -d", gunzip isn't always available
69 autocmd BufReadPre,FileReadPre *.gz,*.bz2 set bin
70 autocmd BufReadPost,FileReadPost *.gz call GZIP_read("gzip -d")
71 autocmd BufReadPost,FileReadPost *.bz2 call GZIP_read("bzip2 -d")
72 autocmd BufWritePost,FileWritePost *.gz call GZIP_write("gzip")
73 autocmd BufWritePost,FileWritePost *.bz2 call GZIP_write("bzip2")
74 autocmd FileAppendPre *.gz call GZIP_appre("gzip -d")
75 autocmd FileAppendPre *.bz2 call GZIP_appre("bzip2 -d")
76 autocmd FileAppendPost *.gz call GZIP_write("gzip")
77 autocmd FileAppendPost *.bz2 call GZIP_write("bzip2")
79 " After reading compressed file: Uncompress text in buffer with "cmd"
81 " set 'cmdheight' to two, to avoid the hit-return prompt
84 " when filtering the whole buffer, it will become empty
85 let empty = line("'[") == 1 && line("']") == line("$")
87 let tmpe = tmp . "." . expand("<afile>:e")
88 " write the just read lines to a temp file "'[,']w tmp.gz"
89 execute "'[,']w " . tmpe
90 " uncompress the temp file: call system("gzip -d tmp.gz")
91 call system(a:cmd . " " . tmpe)
92 " delete the compressed lines
94 " read in the uncompressed lines "'[-1r tmp"
96 execute "'[-1r " . tmp
97 " if buffer became empty, delete trailing blank line
101 " delete the temp file
104 " When uncompressed the whole buffer, do autocommands
106 execute ":doautocmd BufReadPost " . expand("%:r")
110 " After writing compressed file: Compress written file with "cmd"
112 if rename(expand("<afile>"), expand("<afile>:r")) == 0
113 call system(a:cmd . " " . expand("<afile>:r"))
117 " Before appending to compressed file: Uncompress file with "cmd"
119 call system(a:cmd . " " . expand("<afile>"))
120 call rename(expand("<afile>:r"), expand("<afile>"))
125 " This is disabled, because it changes the jumplist. Can't use CTRL-O to go
126 " back to positions in previous files more than once.
128 " When editing a file, always jump to the last cursor position.
129 " This must be after the uncompress commands.
130 autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
133 endif " has("autocmd")