"----------------------------------------------------------------------- " Vim settings file for Ciaran McCreesh " " I finally added some comments, so you can have some vague idea of " what all this does. " " Most recent update: Tue 30 Nov 2004 17:22:34 GMT " " Get the latest version from: " http://dev.gentoo.org/~ciaranm/configs/vimrc " "----------------------------------------------------------------------- "----------------------------------------------------------------------- " settings "----------------------------------------------------------------------- set textwidth=72 set dictionary=/usr/share/dict/words set noexpandtab set keywordprg=dict set ruler set smarttab " Don't be compatible with vi set nocompatible " Enable a nice big viminfo file set viminfo='1000,f1,:1000,/1000 " Make backspace delete lots of things set backspace=indent,eol,start set backspace=2 " Don't create backups set nowritebackup " Show us the command we're typing set showcmd " Highlight matching parens set showmatch " Search options: incremental search, do clever case things, highlight " search set incsearch set ignorecase set infercase set hlsearch " Show full tags when doing search completion set showfulltag " Speed up macros set lazyredraw " No annoying error noises set noerrorbells " Try to show at least three lines and two columns of context when " scrolling set scrolloff=3 set sidescrolloff=2 " Wrap on these set whichwrap+=<,>,[,] " Use the cool tab complete menu set wildmenu " Enable syntax highlighting syntax on " Set our fonts if has("gui_kde") set guifont=Luxi\ Mono/11/-1/5/50/0/0/0/0/0 elseif has("gui_gtk") set guifont=Monospace\ 8 endif if has('gui') call LoadColourScheme("oceandeep:elflord") else call LoadColourScheme("elflord") endif " No icky toolbar or menu in the GUI "if has('gui') " set guioptions-=m " set guioptions-=T "end " By default, go for an indent of 4 set shiftwidth=4 set softtabstop=4 " Do clever indent things. Don't make a # force column zero. set autoindent set smartindent inoremap # X# " Enable folds set nofoldenable set foldmethod=indent set foldlevel=1 set foldcolumn=1 " Syntax when printing set popt+=syntax:y " Enable filetype settings filetype on filetype plugin on filetype indent on " Enable modelines set modeline " Nice statusbar set laststatus=2 fun! SetStatusLine() let l:s1="%-3.3n\\ %f\\ %h%m%r%w" let l:s2="[%{strlen(&filetype)?&filetype:'none'},%{&encoding},%{&fileformat}]" let l:s3="%=\\ 0x%-8B\\ \\ %-14.(%l,%c%V%)\\ %<%P" execute "set statusline=" . l:s1 . l:s2 . l:s3 endfun call SetStatusLine() " Include $HOME in cdpath let &cdpath=','.expand("$HOME") " Perl specific options let perl_include_pod=1 let perl_fold=1 let perl_fold_blocks=1 " Show tabs and trailing whitespace visually set list listchars=tab:>-,trail:.,extends:> " Settings for taglist.vim let Tlist_Use_Right_Window=1 let Tlist_Auto_Open=0 let Tlist_Enable_Fold_Column=0 let Tlist_Compact_Format=1 let Tlist_WinWidth=28 let Tlist_Exit_OnlyWindow=1 let Tlist_File_Fold_Auto_Close = 1 nnoremap :Tlist " Settings minibufexpl.vim let g:miniBufExplModSelTarget = 1 " Settings for showmarks.vim let g:showmarks_enable=1 " Settings for explorer.vim let g:explHideFiles='^\.' " Settings for netrw let g:netrw_list_hide='^\.,~$' " Settings for :TOhtml let html_number_lines=1 let html_use_css=1 let use_xhtml=1 "----------------------------------------------------------------------- " autocmds "----------------------------------------------------------------------- " If we're in a wide window, enable line numbers. fun! WindowWidth() if winwidth(0) > 90 setlocal number " If possible, try to use a narrow number column. if v:version >= 700 try setlocal numberwidth=3 catch endtry endif endif endfun " Force active window to the bottom of the screen without losing its " size. fun! WindowToBottom() let l:h=winheight(0) wincmd J execute "resize" l:h endfun " Update .*rc header fun! UpdateRcHeader() let l:c=col(".") let l:l=line(".") 1,10s-\(Most recent update:\).*-\="Most recent update: ".strftime("%c")- call cursor(l:l, l:c) endfun " Sorry Ciaran, I haven't even found out what the heck an autocmd is " yet. --Tom " " My autocmds augroup ciaranm autocmd! " Automagic line numbers autocmd BufEnter * :call WindowWidth() " Update header in .vimrc and .bashrc before saving autocmd BufWritePre *vimrc :call UpdateRcHeader() autocmd BufWritePre *bashrc :call UpdateRcHeader() " Always do a full syntax refresh autocmd BufEnter * syntax sync fromstart " For help files, move them to the bottom window and make " behave like (jump to tag) autocmd FileType help :call WindowToBottom() autocmd FileType help nmap " For svn-commit, don't create backups autocmd BufRead svn-commit.tmp :setlocal nobackup " Detect procmailrc autocmd BufRead procmailrc :setfiletype procmail augroup END "----------------------------------------------------------------------- " mappings "----------------------------------------------------------------------- " Find a buffer with the given number (ordering is such that the first " entry shown in minibufexpl is 1, the second is 2 and so on). If " there's already a window open for that buffer, switch to it. Otherwise " switch the current window to use that buffer. fun! SelectBuffer(wantedbufnum) let l:buflast = bufnr("$") let l:bufidx = 0 let l:goodbufcount = 0 while (l:bufidx < l:buflast) let l:bufidx = l:bufidx + 1 if buflisted(l:bufidx) let l:bufname = bufname(l:bufidx) if (strlen(l:bufname)) && \ getbufvar(l:bufidx, "&modifiable") == 1 && \ l:bufname != '-MiniBufExplorer-' let l:goodbufcount = l:goodbufcount + 1 if l:goodbufcount == a:wantedbufnum let l:winnr = bufwinnr(l:bufidx) if l:winnr > -1 execute l:winnr . "wincmd w" else execute "buffer " . l:bufidx endif break endif endif endif endwhile endfun " Buffer switches nmap :call SelectBuffer( 1) nmap :call SelectBuffer( 2) nmap :call SelectBuffer( 3) nmap :call SelectBuffer( 4) nmap :call SelectBuffer( 5) nmap :call SelectBuffer( 6) nmap :call SelectBuffer( 7) nmap :call SelectBuffer( 8) nmap :call SelectBuffer( 9) nmap :call SelectBuffer(10) " Commonly used commands nmap :silent nohlsearch nmap :bd nmap :so % nmap :make nmap :pop " Insert a single char noremap ,i ir " Pull the following line to the cursor position noremap ,J :s/\%#\(.*\)\n\(.*\)/\2\1 " In notmal mode, jj escapes inoremap jj " Select everything noremap ,gg ggVG " Reformat everything noremap ,gq gggqG "----------------------------------------------------------------------- " vim: set shiftwidth=4 softtabstop=4 expandtab tw=72 : "----------------------------------------------------------------------- " Stuff I nicked from Tom Gilbertt " First of all, lets have some general editing goodness: " ,cel = "clear empty lines" " - delete the *contents* of all lines which contain only whitespace. " note: this does not delete 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 " =================================================================== " Great for mail formatting - seeing as Ciaran uses that crappy excuse " for a mail client called Sylpheed<,> we want lots of nice things to " speed up editing. " Part 3 - Change Quoting Level map ,dp vip: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 " <,>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 " -------------------------------------- " Other stuff, that's all me let ebuild_error_on_trailing_whitespace=1 " Arg set winaltkeys=no " Do latex-suite things. set grepprg=grep\ -nH\ $* "----------------------------------------------------------------------- "vim: set shiftwidth=4 softtabstop=4 expandtab tw=72 :