" Rod's .vimrc/.gvimrc file (Rod Moffitt rod@rod.info) " $Id: vimrc,v 1.57 2009-12-12 00:13:15 rmoffitt Exp $ " Copyright (C) Rod Moffitt + others " " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License " as published by the Free Software Foundation; either version 2 " of the License, or (at your option) any later version. " " This program is distributed in the hope that it will be useful, " but WITHOUT ANY WARRANTY; without even the implied warranty of " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " GNU General Public License for more details. " " You should have received a copy of the GNU General Public License " along with this program; if not, write to the Free Software " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. set nocompatible " use Vim defaults (much better!) set ts=3 "number of spaces a tab is converted to set sw=3 "number of spaces to use for each indent set expandtab " expand all tabs set nu " enable line numbering set mouse=hv " only allow mouse interactivity during :help set hidden " allow buffers to remain modified without writing set bs=2 " allow backspacing over everything in insert mode set ai " always set autoindenting on " remap shift-insert to paste highlighted text, like the middle mouse button map! set viminfo='20,\"50 " read/write a .viminfo file, don't store more than 50 lines of registers "set tw=78 " uncomment to wrap text set tw=0 " disable wrapping of text let g:leave_my_textwidth_alone = 1 " avoid text wrapping altogether "set backup " uncomment to keep a backup file "set ch=2 " uncomment to make command line two lines high "set noguipty " uncomment to make external commands work through a pipe instead of a pty set vb t_vb= " no annoying visual/audible bells! set history=1000 " 1000 entry history table set undolevels=10000 " 10000 undo levels (WARNING: this can take a lot of memory!) set noequalalways " don't auto-resize when a window is closed set guioptions-=T " disable the toolbar set guioptions-=r " disable the right hand scrollbar set guioptions-=R " disable the right hand scrollbar for vertically split window set guioptions-=l " disable the left hand scrollbar set guioptions-=L " disable the left hand scrollbar for vertically split window set guioptions-=b " disable the bottom/horizontal scrollbar set guioptions-=m " disable the menu " alias E, Q and W to lower case equivalents for convenience cabbrev E e cabbrev Q q cabbrev W w " restore Q as the line formatter (also, make it a single " keystroke by adding ) nnoremap Q gq " font selection "set guifont=-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1 "set guifont=10x20 " same as -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-1 "set guifont=9x15 "set guifont=8x13 " same as -misc-fixed-medium-r-normal--13-100-100-100-c-80-iso8859-1 "set guifont=7x13 "set guifont=6x12 "set guifont=5x8 "set guifont=fixed "set guifont=Terminal\ 12 "set guifont=Luxi\ Mono\ 11 "set guifont=Monotype.com\ 11 "set guifont=OCR\ 2\ SSi\ 10 "set guifont=Fixed\ 11 "set guifont=Terminus\ 10 set guifont=Terminus\ 13 " make :Man command avaliable source $VIMRUNTIME/ftplugin/man.vim " Default MANPAGER vimmanpager doesn't play well " with the :Man command and we don't want to see raw colour codes " so we use sed to strip them. let $MANPAGER = "sed -e 's:\\x1B\\[[[:digit:]]\\+m::g'" let SVNCommandDeleteOnHide=1 let SVNCommandEdit='split' let CVSCommandDeleteOnHide=1 let CVSCommandEdit='split' function! Rod_beg_diff() if filereadable('.svn/entries') if exists("g:loaded_svncommand") execute ':SVNVimDiff' else echo "*** ERROR: svncommand.vim was not loaded" endif elseif filereadable('CVS/Entries') if exists("g:loaded_cvscommand") execute ':CVSVimDiff' else echo "*** ERROR: cvscommand.vim was not loaded" endif else echo "*** ERROR: Unable to find CVS or SVN files" endif endfunction function! Rod_end_diff() execute ':diffoff!' if filereadable('.svn/entries') if exists("g:loaded_svncommand") execute ':SVNGotoOriginal' else echo "*** ERROR: svncommand.vim was not loaded" endif elseif filereadable('CVS/Entries') if exists("g:loaded_cvscommand") execute ':CVSGotoOriginal' else echo "*** ERROR: cvscommand.vim was not loaded" endif else echo "*** ERROR: Unable to find CVS or SVN files" endif endfunction " enable C style indenting for C/C++, auto-wrap comments at 80 characters augroup c au! autocmd BufRead *.c,*.cpp,*.h set formatoptions=rocql cindent textwidth=80 comments=sr:/*,mb:*,el:*/,:// augroup END " enable C style indenting for PHP, auto-wrap comments at 80 characters augroup php au! au BufRead *.php set formatoptions=rocql cindent textwidth=80 comments=sr:/*,mb:*,el:*/,://,:# augroup END " add support for second life LSL scripts, also enable C style indenting, " auto-wrap comments at 80 characters augroup lsl au! au BufNewFile,BufRead *.lsl setf lsl au BufRead *.lsl set formatoptions=rocql cindent textwidth=80 comments=:// augroup END if has("cscope") set csto=0 " search with cscope first, then with ctags set cst " search both ctags and cscope set nocsverb " disable db error on load " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb " restore db load error display " CTRL + backslash to find refs to the function nnoremap :cs find 3 =expand("") " CTRL + underscore then a single character invokes a cs feature " s: Find this C symbol " g: Find this definition " d: Find functions called by this function " c: Find functions calling this function " t: Find this text string " e: Find this egrep pattern " f: Find this file " i: Find files #including this file noremap s :cs find s =expand("") noremap g :cs find g =expand("") noremap c :cs find c =expand("") noremap t :cs find t =expand("") noremap e :cs find e =expand("") noremap f :cs find f =expand("") noremap i :cs find i ^=expand("")$ noremap d :cs find d =expand("") " CTRL + spacebar then a single character does the same yet " in a new horizontal window noremap s :scs find s =expand("") noremap g :scs find g =expand("") noremap c :scs find c =expand("") noremap t :scs find t =expand("") noremap e :scs find e =expand("") noremap f :scs find f =expand("") noremap i :scs find i ^=expand("")$ noremap d :scs find d =expand("") endif " version 5+ commands if version >= 500 " disable highlighting strings inside C comments let c_comment_strings=0 " reset and enable syntax highlighting hi clear Normal set bg& hi clear syntax reset syntax on " switch off search pattern highlighting se nohlsearch " hide the mouse pointer while typing set mousehide " set some nice colors set background=dark hi Normal guifg=white guibg=#00006C hi Normal ctermfg=white hi LineNr guifg=darkgrey hi LineNr ctermfg=darkgrey hi title guifg=darkgrey hi title ctermfg=darkgrey hi VertSplit gui=NONE guifg=cyan guibg=blue hi VertSplit gui=NONE ctermfg=blue ctermbg=cyan hi StatusLineNC gui=NONE guifg=cyan guibg=blue hi StatusLineNC gui=NONE ctermfg=blue ctermbg=cyan hi StatusLine gui=bold guifg=blue guibg=cyan hi StatusLine gui=bold ctermfg=cyan ctermbg=white endif " version 6+ commands if version >= 600 " disable folding set nofoldenable " enable file type detection with plugin and indent loading filetype plugin indent on endif " version 7+ commands if version >= 700 " enable auto-spelling se spell setlocal spell spelllang=en_us " set a spell file where new words are added with 'zg' set spellfile=~/.vim.spell.add endif " configure the Tag List plugin let Tlist_Highlight_Tag_On_BufEnter=1 let Tlist_GainFocus_On_ToggleOpen=1 let Tlist_File_Fold_Auto_Close=0 let Tlist_Process_File_Always=1 let Tlist_Enable_Fold_Column=0 let Tlist_Compact_Format=1 let Tlist_Show_One_File=0 let Tlist_Auto_Update=1 let Tlist_Auto_Open=0 " " configure the minibufexplorer plugin " nnoremap :MBEbp " nnoremap :MBEbn " F3 shows the taglist (and disables spell check), shift-F3 turns it off " this requires the Tag List plugin (see http://rod.info/HowToVim for links) nnoremap :TlistOpen:setlocal nospell nnoremap :TlistClose if has("cscope") " ctrl-shift-F3 reloads the cscope database from the current directory nnoremap :echo "rebuilding cscope database...":call system("cscope -qb"):cs kill -1::cs add . endif " " map shift-left to previous buffer and shift-right to next buffer " " this requires the minibufexplorer plugin (see http://rod.info/HowToVim for links) " nnoremap :MiniBufExplorer " nnoremap :CMiniBufExplorer " F6 selects all text and copies it to the clipboard, shift-F6 does a paste, also " restoring the position which is lost during the select all nnoremap :let save_cursor = getpos(".")ggVG"+y:call setpos('.', save_cursor) nnoremap :let save_cursor = getpos(".")ggVG"+gP:call setpos('.', save_cursor) if version >= 700 " the following enables spelling with F7 and disables it with shift-F7 nnoremap :setlocal spell spelllang=en_us nnoremap :setlocal nospell " map shift-left to previous tab and shift-right to next tab nnoremap :tabp nnoremap :tabn endif " F9 performs a CVS/SVN diff using the plugins, shift-F9 cancels the diff, " these require the CVS/SVN plugins (see http://rod.info/HowToVim for links) nnoremap :call Rod_beg_diff() nnoremap :call Rod_end_diff() " F10 is mapped to the cumbersome chore of inserting a doxygen header with CVS fields with my credentials nnoremap :1i="/*\! \\file " . substitute(bufname("%"), "^.*\/", "", "g") . "\n \\brief \n\\author Rod Moffitt\n\\date \$Date\$\n\\version \$Revision\$ */\n\n/\*\ $Id\$\nCopyright (C) " . substitute(system("date +'%G'"), "\n", "", "g") . " Rod Moffitt rod@rod.info http://rod.info */\n\n" " shift-F10 is mapped to another ritual of appending my vim preferences to the end of the file nnoremap :$o/* vim: sw=3 ts=3 expandtab */ " F11 toggles the menu on and off, shift-F11 toggles the toolbar and " ctrl-shift-F11 toggles the vertical scrollbar (all of which are " disabled by default in this vimrc) nnoremap :if &go=~#'m'set go-=melseset go+=mendif nnoremap :if &go=~#'T'set go-=Telseset go+=Tendif nnoremap :if &go=~#'r'set go-=relseset go+=rendif if version >= 600 " config session saving and bind in F12 to save the current session set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize nnoremap :mksession! ~/.vim.session endif