" Rimon Barr's .vimrc file " Last change: 2005 Jul 01 " Download latest from: " http://www.cs.cornell.edu/barr/repository/files/.vimrc " Comments and suggestions to: " rimon.barr@cornell.edu version 6.0 if has("eval") let mysyntaxfile="~/shell/mysyntax.vim" let bash_is_sh=1 endif if has("user_commands") com! Resource :so ~/.vimrc endif set nocompatible " vim defaults set bs=2 " allow backspacing over everything in insert mode set autoindent " always set autoindenting on set textwidth=78 " always limit the width of text to 78 set nobackup " don't leave backup files in dir (swap files " work well enough for recovery) set background=dark " set the colour schema to something reasonable set complete=.,w,b,t " word completion rules set errorbells " signal errors set visualbell " flashes screen instead of beeping set expandtab " expands tabs to spaces set ignorecase " case insensitive search (default) set smartcase " search is case-insensitive until caps set incsearch " incremental search mode set infercase " correct case during completion set nojoinspaces " joining won't care about punctuation (.!?) set laststatus=2 " status line only when there are two windows set magic " magic characters in search on set nomore " do not pause screenfulls of output set noruler " no ruler (status line) if has("statusline") set statusline=%<%F%=%([%M%R%H%W]\ %)%l,%c%V\ %P\ (%n) endif " set statusline format set scrolloff=2 " set number of scroll padding lines set shortmess=aOtI " shorter messages set cmdheight=2 " size of command area set showmatch " show matching parens for short time set matchtime=50 " set show match time to 5 seconds set showmode " show the vim editing mode set tabstop=2 " size of tab displayed set softtabstop=2 " how many spaces = tab set shiftround " shift at columns that are indent multiples set shiftwidth=2 " autoindent size set smarttab " spaces at beginning of line, tabs elsewhere set showbreak=\\ " indicator for wrapped lines set viminfo='50,h set wildmenu set wildmode=list:longest " gui options behave mswin set guicursor=a:blinkon0 " switch off blinking set guioptions=mrbi " menus, scrollbars, toolbars set guifont=Courier\ 10\ Pitch\ Bold\ 10,-b&h-lucidatypewriter-bold-r-normal-*-*-100-*-*-m-*-iso8859-1,9x15bold,8x13bold,8x13,Fixedsys,Console8x16 " should set this to something nice on X, " and to Fixedsys on Win32 if has("user_commands") com! LargeFont :set guifont=-b&h-lucidatypewriter-bold-r-normal-*-*-140-*-*-m-*-iso8859-1 com! SmallFont :set guifont=-b&h-lucidatypewriter-bold-r-normal-*-*-100-*-*-m-*-iso8859-1 endif if has("gui_running") set lines=50 " try to make a larger window for guis endif if has("mouse") set mouse=a " modes for mouse selection set mousehide " hide mouse when typing set mousemodel=popup_setpos " bring up popup rather than selecting endif set suffixes=.bak,~,.o,.h,.info,.swp,.obj,.class,.doc,.aux,.log,.dvi " file names to leave to end during completion " matching sequence " possible tag files set tags=./tags,./TAGS,tags,TAGS,~/jist-cvs/src/tags,~/glomosim/tags,~/ns/tags set path=./**,/home/barr/1rim/** " path to use for find command "set whichwrap= if has("autocmd") " set window title auto BufEnter * let &titlestring="VIM - ".expand("%:p") endif " set terminal-specific options if has("terminfo") set t_Co=8 set t_Sf=^[[3%p1%dm set t_Sb=^[[4%p1%dm else set t_Co=8 set t_Sf=^[[3%dm set t_Sb=^[[4%dm endif " syntax and search highlighting when we have colours or gui "if &t_Co > 2 || has("gui_running") if has("gui_running") syntax on set hlsearch else syntax off set nohlsearch endif syntax sync clear syntax sync fromstart " colours function! SetRimonCol() hi clear hi Normal guibg=#000080 guifg=#ffff00 hi Comment guifg=#80a0ff hi Cursor guibg=red guifg=black hi IncSearch gui=None guibg=red guifg=black hi Directory guifg=red hi Visual gui=none guifg=fg guibg=#003000 "hi DiffAdd "hi DiffChange "hi DiffText "hi DiffDelete hi StatusLine gui=none guifg=darkblue guibg=yellow hi statuslinenc gui=none guifg=yellow guibg=blue hi VertSplit gui=none guifg=darkgrey guibg=darkblue "hi StatusLine gui=none guifg=white guibg=darkblue "hi StatusLineNC gui=none guifg=darkgrey guibg=#333333 "hi VertSplit gui=none guifg=darkgrey guibg=#333333 hi Search guibg=bg guifg=red hi Folded guibg=bg guifg=#ff00ff hi FoldColumn guibg=#000060 guifg=#ff00ff hi LineNr guibg=bg guifg=#ff00ff "hi ErrorMsg guibg=bg guifg=red "hi SpecialKey guifg=darkgray hi Conditional guifg=white hi Exception guifg=white hi Operator guifg=white hi Label guifg=white hi Type guifg=white hi Repeat guifg=white hi cStatement guifg=white hi Statement guifg=white hi spyce guifg=#ff8888 hi MatchParen gui=bold guibg=Black guifg=Red endfunction nmap col call SetRimonCol() com! RimCol call SetRimonCol() call SetRimonCol() colo desert " par formatting nmap \j gqap nmap gqap nmap gqap nmap ,j gqap vmap gq vmap gq vmap ,j gq omap gqap omap gqap omap ,j gqap imap gqap imap gqap imap ,j gqap " buffer management set hidden " allow unsaved hidden buffers map :bp! map :bn! "map :ls map SelBuff map :bd " cut, copy, paste vmap "+x vmap "+y nmap "+gP imap "+gP noremap " switching between panes map w imap w cmap : map W imap W cmap : " close panes map c imap c cmap " save map :w! imap cmap if has("gui") " bring up system menu map :simalt ~ imap :simalt ~ cmap " maximise map :simalt ~x map :simalt ~r map :simalt ~n endif " get rid of if has("user_commands") " remove ^M from the file com! RemoveCtrlM :%s/^M/\r/g " change to directory of current file com! CD cd %:p:h endif " date stamp map ,date O:.!"c:/program files/cygwin/bin/date" -I$a:60i-O " abbreviations iab rimweb http://www.cs.cornell.edu/barr iab rimresume http://www.cs.cornell.edu/barr/resume.html iab atb All the best,Rimon. imap ,sig :-1r ~/.sig nmap ,sig :-1r ~/.sig " project nmap :Project " shell window if has("python") && has("eval") let g:vimsh_sh="/bin/tcsh" endif nmap sh :source ~/.vim/sh/vimsh.vim nmap sh " winmanager map :WMToggle map :FirstExplorerWindow map :BottomExplorerWindow if has("eval") let g:persistentBehaviour=0 endif " some programming modes map :wa:make map :wa:make run let Checkstyle_Classpath = '/home/barr/bin/checkstyle/checkstyle-all-3.1.jar' let Checkstyle_XML = '/home/barr/bin/checkstyle/docs/sun_checks.xml' " filetype filetype plugin on filetype indent on set shellslash " set iskeyword+=: map IMAP_JumpForward map IMAP_JumpBack if has("eval") let g:Tex_AutoFolding=0 let g:Tex_DefaultTargetFormat='dvi' let g:Tex_CompileRule_dvi='latex -interaction=nonstopmode -src-specials $*' let g:Tex_CompileRule_pdf='pdflatex -interaction=nonstopmode -src-specials $*' endif if has("autocmd") "au BufRead * set formatoptions=tcql nocindent wrap comments& tw=78 augroup detectfiletype au BufRead,BufNewFile *.spy,*.spi set filetype=spyce au BufRead,BufNewFile *.pc set filetype=c au BufRead,BufNewFile *.bsh set filetype=java au BufRead,BufNewFile *.jpy set filetype=python augroup END augroup prog au! au BufRead *.c,*.cc,*.h,*.java,*.C,*.cpp,*.pc,*.cs,*.py set formatoptions=croql cindent nowrap comments=sr:/*,mb:*,el:*/,:// tw=0 au BufEnter *.java nmap :w\|:!javac -source 1.4 % au BufEnter *.c,*.cc nmap :w\|:!gcc % au BufEnter *.pc nmap :w\|:!pcc % au BufEnter *.cs nmap :w\|:!mcs -unsafe -g -out:%e % au BufLeave *.java,*.c,*.cc,*.pc,*.cs nunmap au BufEnter *.c,*.cc,*.h,*.java,*.pc,*.cs nmap ]m|nmap [m au BufLeave *.c,*.cc,*.h,*.java,*.pc,*.cs nunmap |nunmap au BufEnter *.c,*.cc,*.h,*.java,*.pc,*.cs inoremap { {}-a au BufLeave *.c,*.cc,*.h,*.java,*.pc,*.cs iunmap { au BufEnter *.c,*.cc,*.h,*.java,*.C,*.cpp,*.pc,*.cs nmap \// O/49a/o-$a au BufLeave *.c,*.cc,*.h,*.java,*.C,*.cpp,*.pc,*.cs nunmap \// au BufEnter *.tex nmap \// O%49a%o%%-$a au BufLeave *.tex nunmap \// augroup END augroup mail autocmd BufNewFile,BufRead */.Postponed/* set filetype=mail autocmd BufNewFile,BufRead /tmp/pico.* set filetype=mail autocmd BufNewFile,BufRead *.txt set filetype=human autocmd FileType mail set formatoptions+=t textwidth=72 autocmd FileType mail imap ZZ ZZ augroup END augroup spyce au! au BufEnter *.spy,*.spi nmap :w\|:!spyce -o %:r.html % au BufLeave *.spy,*.spi nunmap augroup END augroup vimrc au! au BufEnter *vimrc,*.vim nmap :w:so % au BufLeave *vimrc,*.vim nunmap augroup END augroup python au! au FileType python nmap :w:!% augroup END augroup makefile au! au BufEnter * set expandtab au BufEnter Makefile set noexpandtab au BufEnter makefile set noexpandtab augroup END augroup tex au! "autocmd BufRead * unmap ^X au BufEnter *.tex map ,dvi :!xdvi %< & au BufEnter *.tex map ,tex :w:!pdflatex % au BufEnter *.tex map ,tex au BufEnter *.tex imap ,tex au BufLeave *.tex nunmap au BufEnter *.tex set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*} au BufEnter *.tex set efm=%E!\ LaTeX\ %trror:\ %m, \%E!\ %m, \%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#, \%+W%.%#\ at\ lines\ %l--%*\\d, \%WLaTeX\ %.%#Warning:\ %m, \%Cl.%l\ %m, \%+C\ \ %m., \%+C%.%#-%.%#, \%+C%.%#[]%.%#, \%+C[]%.%#, \%+C%.%#%[{}\\]%.%#, \%+C<%.%#>%.%#, \%C\ \ %m, \%-GSee\ the\ LaTeX%m, \%-GType\ \ H\ %m, \%-G\ ...%.%#, \%-G%.%#\ (C)\ %.%#, \%-G(see\ the\ transcript%.%#), \%-G%*\\s, \%+O(%f)%r, \%+P(%f%r, \%+P\ %\\=(%f%r, \%+P%*[^()](%f%r, \%+P[%\\d%[^()]%#(%f%r, \%+Q)%r, \%+Q%*[^()])%r, \%+Q[%\\d%*[^()])%r 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 au BufReadPre,FileReadPre *.gz set bin au BufReadPost,FileReadPost *.gz let ch_save = &ch|set ch=2 au BufReadPost,FileReadPost *.gz '[,']!gunzip au BufReadPost,FileReadPost *.gz set nobin au BufReadPost,FileReadPost *.gz let &ch = ch_save|unlet ch_save au BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") au BufWritePost,FileWritePost *.gz !mv :r au BufWritePost,FileWritePost *.gz !gzip :r au FileAppendPre *.gz !gunzip au FileAppendPre *.gz !mv :r au FileAppendPost *.gz !mv :r au FileAppendPost *.gz !gzip :r augroup END endif