~ blu3ness /.vimrc

Pretty basic vim setup, has all the bells and whistles, very functional.
" ==== Look and Feel ====
" Use Vim settings, rather then Vi settings (much better!).
set nocompatible
set directory=/var/tmp
set tags=./tags,tags,~/tags
highlight Pmenu guibg=brown gui=bold
:hi LineNr ctermfg=darkcyan
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set cmdheight=2 " command line height
set bs=2
set laststatus=2 " occasions to show status line, 2=always.
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set showcmd		" display incomplete commands
set incsearch		" do incremental searching
set showmode            " show mode at bottom of screen
set tabstop=2
set shiftwidth=2
set expandtab
set smartcase
set ignorecase
set grepprg=grep\ -nH\ $*
set autowrite
set nu
set statusline=%<%f%<%{FileTime()}%<%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
set rulerformat=%15(%c%V\ %p%%%)
"set rulerformat=%<%f%<%{FileTime()}%<%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
set autoindent		" always set autoindenting on
set hlsearch
syntax on
" ==== Scripts and Commands, filetype plugins===
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=70
  autocmd FileType html,xml,xsl source ~/.vim/scripts/closetag.vim
  " 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
  autocmd BufEnter * lcd %:p:h
  augroup END
endif " has("autocmd")

" === Keybindings ===
abbreviate #l # ===<++>===
map <F2> a<C-R>=strftime("%c")<CR><Esc>     
:nnoremap <Esc>P  P'[v']=
:nnoremap <Esc>p  p'[v']=
" ^s to save
inoremap <C-s> <esc>:w<cr>a
nnoremap <C-s> :w<cr>
map Q gq

" === Functions ===
fu! FileTime()
        let ext=tolower(expand("%:e"))
        let fname=tolower(expand('%<'))
        let filename=fname . '.' . ext
        let msg=""
        let msg=msg." ".strftime("(Modified %b,%d %y %H:%M:%S)",getftime(filename))
        return msg
endf

fu! CurTime()
        let ftime=""
        let ftime=ftime." ".strftime("%b,%d %y %H:%M:%S")
        return ftime
endf 

function! InsertCloseTag()
  if &filetype == 'html'

    " list of tags which shouldn't be closed:
    let UnaryTags = ' Area Base Br DD DT HR Img Input LI Link Meta P Param '

    " remember current position:
    normal mz

    " loop backwards looking for tags:
    let Found = 0
    while Found == 0
      " find the previous <, then go forwards one character and grab the first
      " character plus the entire word:
      execute "normal ?\<LT>\<CR>l"
      normal "zyl
      let Tag = expand('<cword>')

      " if this is a closing tag, skip back to its matching opening tag:
      if @z == '/'
        execute "normal ?\<LT>" . Tag . "\<CR>"

      " if this is a unary tag, then position the cursor for the next
      " iteration:
      elseif match(UnaryTags, ' ' . Tag . ' ') > 0
        normal h

      " otherwise this is the tag that needs closing:
      else
        let Found = 1

      endif
    endwhile " not yet found match

    " create the closing tag and insert it:
    let @z = '</' . Tag . '>'
    normal `z
    if col('.') == 1
      normal "zP
    else
      normal "zp
    endif

  else " filetype is not HTML
    echohl ErrorMsg
    echo 'The InsertCloseTag() function is only intended to be used in HTML ' .
      \ 'files.'
    sleep
    echohl None

  endif " check on filetype

endfunction " InsertCloseTag()