~ debay /.vimrc

Relatively standard vimrc with common configuration for searching, whitespace handling, navigation, etc. There are some interesting shortcuts and customizations sprinkled throughout that I've come across over time.
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif

" Use Vim rather than Vi settings. Note that this must be first, because it
" changes other options as a side effect.
set nocompatible

" Turn off all audible bells.
set noerrorbells visualbell t_vb=

" Only do this part when compiled with support for autocommands.
if has("autocmd")

    " Enable file type detection.
    " Use the default filetype settings, so that mail gets 'tw' set to 72,
    " 'cindent' is on in C files, etc.
    " Also load indent files, to automatically do language-dependent indenting.
    filetype plugin indent on

    " Put these in an autocmd group, so that we can delete them easily.
    augroup vimrcEx
    au!

    " For all text files set 'textwidth' to 78 characters.
    autocmd FileType text setlocal textwidth=78

    " When editing a file, always jump to the last known cursor position.
    " Don't do it when the position is invalid or when inside an event handler
    " (happens when dropping a file on gvim).
    autocmd BufReadPost *
      \ if line("'\"") > 0 && line("'\"") <= line("$") |
      \   exe "normal g`\"" |
      \ endif

    augroup END

else

    " Always set auto-indenting on.
    set autoindent

endif " has("autocmd")


" Automatically cd to directory of the buffer.
if exists('+autochdir') 
    set autochdir 
else 
    autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ / 
endif


if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
else
  set backup		" keep a backup file
endif

set history=50		" Keep 50 lines of command line history.
set ruler		    " Show the cursor position all the time.
set showcmd		    " Display incomplete commands.

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

" Keep swapfiles in one directory, not littered all over the file system.
set backupdir=~/.vimswaps,/tmp

" Sane handling of whitespace.
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab

" Allow backspacing over everything in insert mode.
set backspace=indent,eol,start

" Configure the status line show something useful.
set statusline=%F%m%r%h%w\ %y\ [%{&ff}]%=[%l,%v][%p%%]\ [%L] 
set laststatus=2    " Ensure status line is visible.

" Searches are case-insensitive if all lowercase. If contain mixed-case,
" search becomes case-sensitive. Only works with 'set ignorecase'.
set smartcase
set ignorecase

" Incremental searching.
set incsearch

" The h and l keystrokes can be made to wrap over lines (so that trying to
" move left past the beginning of a line puts the cursor at the end of the
" line above). This command does that, and also allows ~ (convert case) to
" wrap over lines, and the cursor keys to wrap when in insert mode:
set whichwrap=h,l,~,[,]

" Set a wrap margin of 4 characters at the end of each line
set wm=2

" Get useful auto-completion in command mode.
set wildmenu
set wildmode=list:longest,full

" Load color scheme.
colorscheme candy

" Quickly expand or collapse the current fold.
:nnoremap <space> za

" Re-format paragraph, preserving cursor position
:nmap Q gwap

" Use keys similar to Vim 'hjkl' keys to navigate between tabs.
map <C-L> :tabn<CR>
map <C-H> :tabp<CR>

" Ctrl-. repeats the last macro, assumed to be saved as 'q'.
map <C-.> <ESC>@q

" Map Ctrl-Backspace to delete previous word. I never use this and should
" probably remove it.
map! <C-*> <C-W>

" Abbreviation for inserting the current date.
iab xdate <c-r>=strftime("%F %H:%M:%S")<cr>


"
" Customize various Vim auto-completion features.
"

" The function InsertTabWrapper and the mappings that follow it give the Tab
" character completion behavior in insert mode similar to what's available in
" modern IDEs. Borrowed from: http://vim.wikia.com/wiki/VimTip102.

function! InsertTabWrapper(direction)
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
        return "\<tab>"
    elseif "backward" == a:direction
        return "\<c-p>"
    else
        return "\<c-n>"
    endif
endfunction

inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr>

" Turn on omni-completion for the appropriate file types.
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1  " Rails support



"
" LaTeX
"

" REQUIRED. This makes vim invoke latex-suite when you open a tex file.
filetype plugin on

" Only do this for Vim version 7.0 and later.
if version >= 700

  " Turn on spell checking if it hasn't been enabled yet.
  if !exists("spell_on")
    set spell
  endif

endif

" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash

" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse latex-suite. Set your grep
" program to alway generate a file-name.
set grepprg=grep\ -nH\ $*

if has('mac')
    " FIX: There's an issue with latex-suite finding the PDF viewer on Macs.
    let Tex_ViewRule_pdf = 'open $*.pdf'
endif

" FIX: Vim7 has a problem detecting the filetype correctly when editing a new
" LaTex document
let g:tex_flavor='latex'


"
" Make
"

" Turn off tab expansion for Makefiles
au FileType make setlocal noexpandtab

" Support for Arc
au bufnewfile,bufread	*.arc 	set ft=arc

" Support for Mako Python templates.
autocmd BufNewFile,BufRead *.mako :set filetype=mako


"
" Lisp
"
autocmd BufRead *.lsp,*.lisp so ~/.vim/ftplugin/VIlisp.vim


"
" Scheme
"
if exists("b:is_mzscheme") || exists("is_mzscheme")

    " improve indenting
    setl iskeyword+=#,%,^
    setl lispwords+=module,parameterize,let-values,let*-values,letrec-values
    setl lispwords+=define-values,opt-lambda,case-lambda,syntax-rules,with-syntax,syntax-case
    setl lispwords+=define-signature,unit,unit/sig,compund-unit/sig,define-values/invoke-unit/sig

endif