version 5.4 " Remove ALL auto-commands. This avoids having the " autocommands twice when the vimrc file is sourced again. autocmd! filetype on syntax on "============== " SETTINGS "============== set autoindent set autowrite set backspace=indent,eol,start set nobackup set background=dark set clipboard=autoselect,exclude:cons\|linux set nocompatible set complete=.,b,u,w,t,i,d " buffers used for lookup in autocompletion set cinoptions=>2,e0,n0,}0,^0,:2,=2,p2,t0,(2,)30,*40,+2,f0,{0,c2,u2 set cinkeys=0{,0},!^F,o,O,e,*,0# set comments=s1:/*,mb:*,el:*/,://,b:#,:%,:XCOMM,nb:>,fb:- set dictionary=/usr/share/dict/words set noerrorbells "set equalprg="indent" set esckeys set expandtab set fileformat=unix set formatoptions=cqrtl set helpheight=0 "set hidden set highlight=8r,db,es,hs,mb,Mr,nu,rs,sr,tb,vr,ws set history=100 set nohlsearch set ignorecase set incsearch " iskeyword=@,48-57,_,192-255 (default) set iskeyword=@,48-57,_,192-255,-,.,@-@ set nojoinspaces set keywordprg=dict set laststatus=2 " lazyredraw: do not update screen while executing macros set lazyredraw "set listchars=eol:$,tab:>-,trail:·,extends:» set listchars=tab:»­,trail:· "set list " magic: use some magic in search patterns set magic " modeline: ... " Allow the last few lines to be a modeline - useful when " the last line in sig gives the preferred textwidth for replies. set modeline set modelines=4 set more set mouse=a set nonumber set pastetoggle= set path=.,/home/gilbertt set report=0 set norestorescreen set t_ti= t_te= set ruler set scrolloff=0 set shell=/bin/bash " shiftwidth: Number of spaces to use for each insertion of (auto)indent. set shiftwidth=2 set shiftround " String to put at the start of lines that have been wrapped. set showbreak="+ " " showcmd: Show current uncompleted command set noshowcmd " showmatch: Show the matching bracket for the last ')'? set showmatch set showmode set softtabstop=2 set smartcase set smartindent set smarttab " startofline: do not jump to first character with page commands, " ie keep the cursor in the current column. set nostartofline " suffixes: Ignore filename with any of these suffixes " when using the ":edit" command. set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc set tabstop=2 set tildeop set textwidth=76 set title set ttyfast set undolevels=1000 " undoing 1000 changes should be enough :-) set updatecount=100 " write swap file to disk after each 100 characters set updatetime=6000 " write swap file to disk after 6 inactive seconds " viminfo: What info to store from an editing session " in the viminfo file; can be used at next session. set viminfo=%,'20,\"500,:500,n~/.viminfo set visualbell set whichwrap=<,>,b,s,[,] set wmh=0 if &term =~ "xterm" if has("terminfo") set t_Co=8 set t_Sf=[3%p1%dm set t_Sb=[4%p1%dm else set t_Co=8 " "terminal has eight colors" set t_Sb=[4%dm " escape sequence for background set t_Sf=[3%dm " escape sequence for foreground endif endif if has("autocmd") filetype plugin indent on endif " =================================================================== " Abbreviations " =================================================================== if filereadable(expand("~/.vim/my_abbr.vim")) source ~/.vim/my_abbr.vim endif " " =================================================================== " MAPpings " =================================================================== " " Disable the suspend for ^Z. "map :shell " " When I let Vim write the current buffer I frequently mistype the " command ":w" as ":W" - so I have to remap it to correct this typo: nmap :W :w nmap :Q :q nmap :wQ :wq nmap :WQ :wq nmap :Wq :wq "stop prompting me when there are multiple files! (unless I modified one) "nmap :q :qa map Q gq " Don't use Ex mode, use Q for formatting " " =================================================================== " VIM - Editing and updating the vimrc: " As I often make changes to this file I use these commands " to start editing it and also update it: let vimrc='~/.vimrc' let myabbr='~/.abbr.vimrc' nn ,vu :source =vimrc nn ,ve :edit =vimrc nn ,vy :edit =myabbr " =================================================================== " " General Editing " " ;rcm = remove "control-m"s - for those mails sent from DOS: cmap ;rcm %s///g " " Make whitespace visible: " Sws = show whitespace nmap ,Sws :%s/ /_/g vmap ,Sws :%s/ /_/g " " Sometimes you just want to *see* that trailing whitespace: " Stws = show trailing whitespace nmap ,Stws :%s/ *$/_/g vmap ,Stws :%s/ *$/_/g " " =================================================================== " General Editing " =================================================================== " " ,cel = "clear empty lines" " - delete the *contents* of all lines which contain only whitespace. " note: this does not uelete lines! map ,cel :%s/^\s\+$// " ,del = "delete 'empty' lines" " - delete all lines which contain only whitespace " note: this does *not* delete empty lines! map ,del :g/^\s\+$/d " " ,cqel = "clear quoted empty lines" " Clears (makes empty) all lines which start with '>' " and any amount of following spaces. nmap ,cqel :%s/^[>]\+$// vmap ,cqel :s/^[> ]\+$// " " ,ksr = "kill space runs" " substitutes runs of two or more space to a single space: nmap ,ksr :%s/ \+/ /g vmap ,ksr :s/ \+/ /g " " ,Sel = "squeeze empty lines" " Convert blocks of empty lines (not even whitespace included) " into *one* empty line (within current visual): map ,Sel :g/^$/,/./-j " " ,Sbl = "squeeze blank lines" " Convert all blocks of blank lines (containing whitespace only) " into *one* empty line (within current visual): map ,Sbl :g/^\s*$/,/\S/-j " " =================================================================== " Editing of email replies and Usenet followups - using autocommands " =================================================================== " " " Part 3 - Change Quoting Level map ,dp vip:s/^> // vmap ,dp :s/^> // " " ,qp = "quote current inner paragraph" map ,qp vip:s/^/> / " " ,qp = "quote current paragraph" vmap ,qp :s/^/> / " ,kpq "kill power quote" vmap ,kpq :s/^> *[a-zA-Z]*>/> >/ " " ,fq "fix quoting" vmap ,fq :s/^> \([-":}\|][ ]\)/> > / " " Part 5 - Reformatting Text " " Formatting the current paragraph according to " the current 'textwidth' with ^J (control-j): imap gqap map gqap " " ,j = join line in commented text " (can be used anywhere on the line) nmap ,j Vjgq " " =================================================================== " Editing your reply " =================================================================== " " Put parentheses around "visual text" " " ,) and ,( : vmap ,( v``>a) vmap ,) v``>a) vmap ," c""" " " remove signatures " " ,kqs = kill quoted sig unto start of own signature: map ,kqs G?^> *-- $d/^-- $/ map ,kqq :%g/^> >/d " " Indent a C file. nmap ,ci :w:!indent %:e! nmap ,cci :w:!astyle --style=ansi %:e! " " " =================================================================== " Useful stuff. :-) " =================================================================== " " ,E = execute line map ,E 0/\$w"yy$:yr! " " ,dr = decode/encode rot13 text vmap ,dr :!tr A-Za-z N-ZA-Mn-za-m "vnoremap < >gv " " =================================================================== " Mapping of special keys - arrow keys and function keys. " =================================================================== " Buffer commands (split,move,delete) - " this makes a little more easy to deal with buffers. map :split map :bp map :bn "map :bd map j map k map h map l map j_ map k_ map h_ map l_ " is bound to `complete' inoremap " " cycle fast thru buffers ... nnoremap :bn nnoremap :bp " " cycle fast thru errors ... map :cn map :cp fun! AllIndent() let oldLine=line('.') normal(gg=G) execute ':' . oldLine endfun map -- :call AllIndent() "ChangeLog entry convenience fun! InsertChangeLog() normal(1G) call append(0, strftime("%a %b %d %T %Z %Y") . " Tom Gilbert ") call append(1, "") call append(2, " * ") call append(3, "") execute ':3' normal($) endfun map ,cl :call InsertChangeLog()A " Toggle fold state between closed and opened. " " If there is no fold at current line, just moves forward. " If it is present, reverse its state. fun! ToggleFold() if foldlevel('.') == 0 normal! l else if foldclosed('.') < 0 . foldclose else . foldopen endif endif " Clear status line echo endfun " Map this function to Space key. noremap :call ToggleFold() " =================================================================== " AutoCommands " =================================================================== " " so $VIMRUNTIME/syntax/syntax.vim augroup cprog au! "autocmd BufRead * set formatoptions=trcql autoindent nocindent comments& autocmd FileType c,cpp set noautoindent cindent formatoptions=croql shiftwidth=2 softtabstop=2 textwidth=78 wrapmargin=3 if filereadable(expand("~/.vim/my_c_syntax.vim")) autocmd FileType c,cpp source ~/.vim/my_c_syntax.vim endif autocmd FileType c,cpp hi PreProc ctermfg=lightgrey augroup END augroup html au! autocmd FileType html,php3,php set nocindent autoindent sw=2 ts=8 expandtab augroup END augroup mail au! au BufNewFile,BufRead .letter,mutt*,nn.*,snd.* set tw=72 augroup END " " =================================================================== " TEMPORARY STUFF - TESTING THINGS " =================================================================== " " Some simple example of the "expand modifiers": " insert the current filename *with* path: iab _PATHFILE =expand("%:p") " insert the current filename *without* path: iab _FILE =expand("%:t:r") " insert the path of current file: iab _PATH =expand("%:h") " this means vim will always jump to the last edited line in a file if poss autocmd BufRead *,.* :normal '" " " " configuration of the taglist plugin " =================================== let Tlist_Ctags_Cmd = 'ctags-exuberant' let Tlist_Key = '' let Tlist_Sync_Key = '' let Tlist_Sort_Type = "order" let Tlist_Use_Horiz_Window = 1 let Tlist_Use_Right_Window = 0 let Tlist_Use_One_Window = 1 let Tlist_Auto_Refresh = 1 let Tlist_Auto_Open = 0 let Tlist_Display_Prototype = 0 let Tlist_Inc_Winwidth = 0 let Tlist_WinWidth = 30 " configuration of the bufexplorer plugin " let g:bufExplorerMaxHeight = 8 " let g:bufExplorerOpenMode = 0 " configuration of the minibufexplorer plugin let g:miniBufExplorerMoreThanOne = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBuffs = 1 let g:miniBufExplorerMoreThanOne = 1 map b :MiniBufExplorer " " " vim:tw=78 et sw=2 comments=\:\"