" Vim " An example for a vimrc file. " " To use it, copy it to " for Unix and OS/2: ~/.vimrc " for Amiga: s:.vimrc " for MS-DOS and Win32: $VIM\_vimrc set nocompatible " Use Vim defaults (much better!) set bs=2 " allow backspacing over everything in insert mode set ai " always set autoindenting on set tw=80 " always limit the width of text to 80 set backup " keep a backup file set viminfo='20,\"75 " read/write a .viminfo file, don't store more " than 75 lines of registers set ts=4 "tab stop" set incsearch "incremental searching" set shiftwidth=4 set cino=g0 "C/C++ auto-indent" set noerrorbells "damn this beep ;-)" to quote Sven's rc. set path=..\include,..\src,$PATH set ruler set showcmd set showmatch set suffixes=.swp set visualbell set wildchar= " Support iabs for macros. iab INSERTCLASSNAMEHERE =expand("%:t:r") iab INSERTFILEDEFINEHERE =expand("%:t") " Don't use Ex mode, use Q for formatting map Q gq " Get past the darn weird RS/6000 right-ctrl map w  syntax on augroup cprog " Remove all cprog autocommands au! " When starting to edit a file: " For *.c and *.h 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 BufRead * set formatoptions=tcql nocindent comments& autocmd BufRead *.cpp,*.hpp,*.C,*.c,*.h set formatoptions=cql cindent comments=sr:/*,mb:*,el:*/,:// " C autocmd Macros autocmd BufRead *.cpp map #5 :!g++ " Copyright, comment head, double include protect, and basic class. autocmd BufRead *.c,*.h,*.cpp,*.hpp map #9 :set nocindent A/* Copyright (c) 1999 by Mark Jerde. All Rights Reserved */ /69A*oDOCUMENT $Revision$ $Date$ $RCSfile$ ENDDOCUMENT 69A*A/ #ifndef INSERTFILEDEFINEHERE #define INSERTFILEDEFINEHERE /69A*oDOCUMENT CLASS: INSERTCLASSNAMEHERE OWNER: Mark Jerde PURPOSE: USAGE: STATES: MEMBER FUNCTIONS: public: protected: MEMBER DATA: EXCEPTIONS: REQUIREMENTS: ENDDOCUMENT 69A*A/ class INSERTCLASSNAMEHERE { public: protected: private: }; #endif // INSERTFILEDEFINEHERE :2,$s/\./_/g :set cindent " Comment head. autocmd BufRead *.c,*.h,*.cpp,*.hpp map #8 :set nocindent A/69A*oDOCUMENT CLASS: OWNER: Mark Jerde PURPOSE: USAGE: STATES: MEMBER FUNCTIONS: public: protected: MEMBER DATA: EXCEPTIONS: REQUIREMENTS: ENDDOCUMENT 69A*A/ :set cindent " Insert raw class name. autocmd BufRead *.c,*.h,*.cpp,*.hpp map #6 iINSERTCLASSNAMEHERE " Insert class name with "::". autocmd BufRead *.c,*.h,*.cpp,*.hpp map #5 iINSERTCLASSNAMEHERE:: " Open other file function. Contains work around for *pp 'press enter' bug. "Alternative incomplete function demonstrating how to check if the file exists. autocmd BufRead *.c,*.h,*.cpp,*.hpp map #4 :if expand("%:e") == "hpp" if filereadable("..\\src\\" . expand("%:t:r") . ".cpp") e ../src/%:t:r.cpp elseif expand("%:e") == "cpp" e ../include/%:t:r.hpp elseif expand("%:e") == "h" e ../src/%:t:r.c elseif expand("%:e") == "c" e ../include/%:t:r.h endif "The real working function. autocmd BufRead *.c,*.h,*.cpp,*.hpp map #4 :if expand("%:e") == "hpp" w e ../src/%:t:r.cpp elseif expand("%:e") == "cpp" w e ../include/%:t:r.hpp elseif expand("%:e") == "h" w e ../src/%:t:r.c elseif expand("%:e") == "c" w e ../include/%:t:r.h endif augroup END augroup lispprog " Remove all lisp autocommands au! autocmd BufRead *.lisp set ts=2 autocmd BufRead *.lisp so $VIM/syntax/lisp.vim " Lisp compile command autocmd BufRead *.lisp map #4 :w! %.clisp~ :!clisp -i %.clisp~ :!rm %.clisp~ augroup END augroup javaprog " Remove all java autocommands au! " Java compile command autocmd BufRead *.java map #9 :!javac *.java augroup END augroup templates " Remove all template autocommands au! autocmd BufNewFile *.C source $VIM/templates/C.vim autocmd BufNewFile *.h source $VIM/templates/h.vim augroup END augroup mail " Remove all mail autocommands au! autocmd BufRead /tmp/snd.* set noautoindent ts=8 nobackup writebackup augroup END augroup gzip " Remove all gzip autocommands au! " Enable editing of gzipped files " read: set binary mode before reading the file " uncompress text in buffer after reading " write: compress file after writing " append: uncompress file, append, compress file autocmd BufReadPre,FileReadPre *.gz set bin autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip autocmd BufReadPost,FileReadPost *.gz set nobin autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . %:r autocmd BufWritePost,FileWritePost *.gz !mv :r autocmd BufWritePost,FileWritePost *.gz !gzip :r autocmd FileAppendPre *.gz !gunzip autocmd FileAppendPre *.gz !mv :r autocmd FileAppendPost *.gz !mv :r autocmd FileAppendPost *.gz !gzip :r augroup END