" Rod's .vimrc/.gvimrc file (Rod Moffitt rod@rod.info) " $Id: vimrc,v 1.47 2008-12-07 20:28:54 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!) se ts=3 "number of spaces a tab is converted to se sw=3 "number of spaces to use for each indent se expandtab " expand all tabs se nu " enable line numbering se mouse=hv " only allow mouse interactivity during :help se hidden " allow buffers to remain modified without writing set bs=2 " allow backspacing over everything in insert mode set ai " always set autoindenting on map Q gq " disable Q -> Ex mode, use Q for formatting " 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 " font selection "se guifont=-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1 "se guifont=10x20 " same as -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-1 "se guifont=9x15 "se guifont=8x13 " same as -misc-fixed-medium-r-normal--13-100-100-100-c-80-iso8859-1 "se guifont=7x13 "se guifont=6x12 "se guifont=5x8 "se guifont=fixed "se guifont=Terminal\ 12 "se guifont=Luxi\ Mono\ 11 "se guifont=Monotype.com\ 11 "se guifont=OCR\ 2\ SSi\ 10 "se guifont=Fixed\ 11 "se guifont=Terminus\ 10 se 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'" " F2 is mapped to the cumbersome chore of inserting a doxygen header with CVS fields with my credentials map :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-F2 is mapped to another ritual of appending my vim preferences to the end of the file map :$o/* vim: sw=3 ts=3 expandtab */ " F4 performs a CVS/SVN diff using the plugins, shift-F4 cancels the diff, " these require the CVS/SVN plugins (see http://rod.info/HowToVim for links) map :call Rod_beg_diff() map :call Rod_end_diff() 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 " 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 map :let save_cursor = getpos(".")ggVG"+y:call setpos('.', save_cursor) map :let save_cursor = getpos(".")ggVG"+gP:call setpos('.', save_cursor) " 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 map :cs find 3 =expand("") " CTRL + underscore then a single character invokes a cs feature nmap s :cs find s =expand("") nmap g :cs find g =expand("") nmap c :cs find c =expand("") nmap t :cs find t =expand("") nmap e :cs find e =expand("") nmap f :cs find f =expand("") nmap i :cs find i ^=expand("")$ nmap d :cs find d =expand("") " CTRL + spacebard then a single character does the same yet " in a new horizontal window nmap s :scs find s =expand("") nmap g :scs find g =expand("") nmap c :scs find c =expand("") nmap t :scs find t =expand("") nmap e :scs find e =expand("") nmap f :scs find f =expand("") nmap i :scs find i ^=expand("")$ nmap 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 " config session saving and bind in F12 to save the current session set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize map :mksession! ~/.vim.session 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 " the following enables spelling with F7 and disables it with shift-F7 map :setlocal spell spelllang=en_us map :setlocal nospell " map shift-left to previous tab and shift-right to next tab map :tabp map :tabn endif