" An example for a vimrc file. " " Maintainer: Bram Moolenaar " Last change: 1999 Sep 09 " " Setup by: Zoltan Arpadffy " " To use it, copy it to " for Unix and OS/2: ~/.vimrc " for Amiga: s:.vimrc " for MS-DOS and Win32: $VIM\_vimrc " for VMS: sys$login:.vimrc set nocompatible " Use Vim defaults (much better!) set bs=2 " allow backspacing over everything in insert mode set backup " keep a backup file set viminfo='20,\"50 " read/write a .viminfo file, don't store more " than 50 lines of registers set history=50 " keep 50 lines of command line history set ruler " show the cursor position all the time set autoindent set cmdheight=2 set ignorecase set scs set incsearch set nowrap set tabstop=8 set ttyfast " set fast terminal set expandtab " use space instead of tab " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries " let &guioptions = substitute(&guioptions, "t", "", "g") " Don't use Ex mode, use Q for formatting map Q gq cmap map [4~ $ map [1~ 0 map [5~  map [6~  map  map  map  map  imap  imap  imap  imap  imap cmap [3~ cmap   cmap   cmap  cmap  cmap [1~ cmap [4~ nmap X nmap [3~ x " Make p in Visual mode replace the selected text with the "" register. vnoremap p :let current_reg = @"gvdi=current_reg " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif " Only do this part when compiled with support for autocommands. if has("autocmd") " In text files, always limit the width of text to 78 characters autocmd BufRead *.txt set tw=78 augroup cprog " Remove all cprog autocommands au! " When starting to edit a file: " For C and C++ files set formatting of comments and set C-indenting on. " For other files switch it off. " Don't change the order, it's important that the line with * comes first. autocmd FileType * set formatoptions=tcql nocindent comments& autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,:// augroup END augroup gzip " Remove all gzip autocommands au! " Enable editing of gzipped files " set binary mode before reading the file autocmd BufReadPre,FileReadPre *.gz,*.bz2 set bin autocmd BufReadPost,FileReadPost *.gz call GZIP_read("gunzip") autocmd BufReadPost,FileReadPost *.bz2 call GZIP_read("bunzip2") autocmd BufWritePost,FileWritePost *.gz call GZIP_write("gzip") autocmd BufWritePost,FileWritePost *.bz2 call GZIP_write("bzip2") autocmd FileAppendPre *.gz call GZIP_appre("gunzip") autocmd FileAppendPre *.bz2 call GZIP_appre("bunzip2") autocmd FileAppendPost *.gz call GZIP_write("gzip") autocmd FileAppendPost *.bz2 call GZIP_write("bzip2") " After reading compressed file: Uncompress text in buffer with "cmd" fun! GZIP_read(cmd) let ch_save = &ch set ch=2 execute "'[,']!" . a:cmd set nobin let &ch = ch_save execute ":doautocmd BufReadPost " . expand("%:r") endfun " After writing compressed file: Compress written file with "cmd" fun! GZIP_write(cmd) if rename(expand(""), expand(":r")) == 0 execute "!" . a:cmd . " :r" endif endfun " Before appending to compressed file: Uncompress file with "cmd" fun! GZIP_appre(cmd) execute "!" . a:cmd . " " call rename(expand(":r"), expand("")) endfun augroup END " This is disabled, because it changes the jumplist. Can't use CTRL-O to go " back to positions in previous files more than once. if 0 " When editing a file, always jump to the last cursor position. " This must be after the uncompress commands. autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif endif " Write out file data on live autocmd VimLeave * echo "File:" expand("%") "("line2byte(line("$")+1)-1 "bytes," line("$") "lines )" endif " has("autocmd")