"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Filename: .vimrc " Description: Custom vim (and gvim) configuration) " Author: Harry Mills " Coauthor: Nick Pope, Dave Ingram " Last Updated: Sun Aug 24 20:59:43 BST 2008 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General Settings """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set nocompatible " do not use compatibility mode (must be 1st) set backspace=indent,eol,start " configure backspace behaviour set cmdheight=1 " Commandbar height is 1 set noexpandtab " Expand tabs to spaces set foldlevel=9999 " Expand folds by default set history=500 " How many lines of history to remember set hlsearch " Highlight search set ignorecase " Ignore case when searching set incsearch " Incremental search set linebreak " Break at word boundaries set magic " Allow magic characters in searches or replaces set mat=2 " Matching parens should blink for 2/10 sec "set mouse=a " Always use mouse set noerrorbells " Quiet on errors set number " Do number lines set novisualbell " No visual flash set ruler " Show ruler set shiftwidth=4 " Tabstop = 2 chars (autoindenting) set shortmess+=I " No welcome message set showcmd " Show partial command in statusbar set showmatch " Show matching brackets set t_vb= " No visual flash (termcap) set tabstop=4 " Tabstop = 2 chars set softtabstop=4 " Width of spaces that vim uses as a tab set smarttab " Uses shiftwidth to determine amount to tab by at start of line set autoindent " Automatic indenting set smartindent " Indents more after certain lines (see :help smartindent) set textwidth=0 " Text width = 0 == no autowrapping of text set wildmenu " Wildcard menu set winminheight=0 " No minimum window height set guioptions=aegic " enable autoselect, tabs, grey menu items, " icon, menubar, and console dialogs """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " OS-Specific Settings """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has('win32') || has('win64') " Windows-specific options set guifont=Courier\ New:h10 " set a respectable looking font set shellslash " required for latex-suite else " Assume Linux-specific options " grep sometimes doesn't display file names when searching a single file, " which confuses latex-suite, so let's fix that: set grepprg=grep\ -nH\ $* set shell=zsh endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Colour scheme """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has('gui_running') colorscheme desert else colorscheme desert " or elflord? endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Filetype settings """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" filetype indent plugin on " Indent files please, with omnicompletion syntax on " file formats map fd :set fileformat=dos:w map fm :set fileformat=mac:w map fu :set fileformat=unix:w " Python settings let python_highlight_space_errors = 1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Spell checking """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let spell_executable="aspell" let spell_root_menu="-" let spell_insert_mode=0 let spell_auto_type='' highlight SpellErrors ctermfg=Red map :setlocal spell! spelllang=en_gb """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Highlight space at end of line as error """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" highlight WhitespaceEOL ctermbg=DarkRed guibg=Red match WhitespaceEOL /\s\+$/ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Editing vimrc """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has('win32') || has('win64') " Fast reload of vimrc map vs :source ~/_vimrc " Fast editing of vimrc map ve :sp ~/_vimrc " When vimrc is edited, reload it autocmd! bufwritepost _vimrc source ~/_vimrc else " Fast reload of vimrc map vs :source ~/.vimrc " Fast editing of vimrc map ve :sp ~/.vimrc " When vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Vim Sessions """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " ignore 'options' because of latex-suite (would be pointless to save that!) set sessionoptions=blank,curdir,folds,help,resize,tabpages,winsize if has('win32') || has('win64') set sessionoptions+=slash,unix map ss :mksession! ~/_vimsession map sr :source ~/_vimsession else map ss :mksession! ~/.vim/.session map sr :source ~/.vim/.session endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Functions """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" func! DeleteTrailingWS() norm mz %s/\s\+$//ge norm `z endfunc map ds :call DeleteTrailingWS() map :let &lines=&lines-1 map :let &lines=&lines+1 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Autocommands """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" augroup deltrailws " Remove existing commands in group if defined autocmd! autocmd BufWrite *.[chC] :call DeleteTrailingWS() autocmd BufWrite *.{cc,hh} :call DeleteTrailingWS() autocmd BufWrite *.[ch]{xx,pp,++} :call DeleteTrailingWS() autocmd BufWrite *.{pl,php,java} :call DeleteTrailingWS() autocmd BufWrite *.txt :call DeleteTrailingWS() autocmd BufWrite *.{cls,sty,tex} :call DeleteTrailingWS() augroup end augroup fixfiletype autocmd! autocmd BufNewFile,BufRead *.thtml :set filetype=php autocmd BufRead /var/log/messages* :set filetype=messages augroup end augroup qmv autocmd! autocmd BufRead /tmp/qmv* :set ts=8 augroup end """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Subversion helper """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if !(has('win32') || has('win64')) map :new:read !svn diff:set syntax=diff buftype=nofilegg endif "***************************************************************************** " HTML Formatting Commands "***************************************************************************** " strip tags map h! mz:%s#<\_.\{-}>##g:%s# # #g`z """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Formatting/movement commands """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " format current paragraph and keep cursor in current position noremap Q mzgqap`z " copy to end of line noremap Y y$ " remove search highlight map hh :let @/='' "***************************************************************************** " Automatic Java Commands - TODO: move to ftplugin "***************************************************************************** " Functions function! JavaFold() syn region fold_braces start=/{/ end=/}/ transparent fold keepend extend syn region fold_javadoc start=+/\*\*+ end=+\*/+ transparent fold keepend extend syn match fold_imports /\n\%(import[^;]\+;\n\)\+/ transparent fold function! JavaFoldText() let header = substitute(getline(v:foldstart), '{.*', '{...}', '') return matchstr(foldtext(), '^[^:]*') . ': ' . header endfunction setl foldlevelstart=1 setl foldmethod=syntax setl foldtext=JavaFoldText() endfunction " Autocommand group augroup java_au au! " folding au FileType java call JavaFold() au FileType java setl fen " macros au FileType java inoremap System.out.println();hi " abbreviations au FileType java inoremap $b boolean au FileType java inoremap $i import au FileType java inoremap $pa private au FileType java inoremap $pr private au FileType java inoremap $pu public au FileType java inoremap $r return au FileType java inoremap $s String au FileType java inoremap $v void augroup end """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Automatic JavaScript Commands - TODO: move to ftplugin """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" function! JavaScriptFold() syn region fold_braces start=/{/ end=/}/ transparent fold keepend extend function! JavascriptFoldText() return substitute(getline(v:foldstart), '{.*', '{...}', '') endfunction setl foldlevelstart=1 setl foldmethod=syntax setl foldtext=JavascriptFoldText() endfunction augroup javascript_au au! " folding au FileType javascript call JavaScriptFold() au FileType javascript setl fen " macros au FileType javascript imap console.log();hi au FileType javascript imap alert();hi " abbreviations au FileType javascript inoremap $c /****/ka au FileType javascript inoremap $d //////ka au FileType javascript inoremap $r return " options au FileType javascript setl nocindent augroup end """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Abbreviations """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" iab xdate =strftime("%Y-%m-%d") iab xtime =strftime("%H:%M:%S") iab xdatetime =strftime("%Y-%m-%d %H:%M:%S") iab xlongdate =strftime('%A, %e %B %Y') iab xname Harry Mills iab xcorp University of York iab xdept Department of Computer Science