thayer /.vimrc

" ----------------------------------------------------------------------
" file:     ~/.vimrc
" author:   Thayer Williams - http://cinderwick.ca
" modified: July 27, 2008
" vim:
" ----------------------------------------------------------------------


" general --------------------------------------------------------------

filetype plugin indent on   " ?????????????????????

colorscheme desert      " define syntax color scheme
"colorscheme wombat     " define syntax color scheme
set nocompatible        " disregard vi compatibility
set dir=~/.vim/swap     " keep swap files in one place
set bdir=~/.vim/backup  " keep backups in one place
set encoding=utf-8      " UTF-8 encoding for all new files
"set fileencoding=utf-8  " force filetype encoding for existing files
set termencoding=utf-8  " force terminal encoding
set syntax=on           " enable syntax highlighting
set mouse=a             " make sure mouse is used in all cases
set backspace=2         " full backspacing capabilities (indent,eol,start)
set history=100         " 100 lines of command line history
set number              " show line numbers
set numberwidth=1       " minimum num of cols to reserve for line numbers
set nobackup            " disable backup files (filename~)
set showmatch           " show matching brackets (),{},[]
set ww=h,l,<,>,[,]      " whichwrap -- left/right keys can traverse up/down
set wrap                " wrap long lines to fit terminal width
set ttyfast             " tell vim we're using a fast terminal for redraws
set autoread            " reload file if vim detects it changed elsewhere
set wildmenu            " enhanced tab-completion shows all matching cmds
set splitbelow          " place the new split below the current file
set autowrite           " write file if modified on each :next, :make, etc.
set writebackup         " make a backup before writing a file until successful
set shell=/bin/sh       " set default shell type
set textwidth=80        " insert carriage return after n cols wide
set previewheight=5     " default height for a preview window (def:12)

" statusline -----------------------------------------------------------

set cmdheight=1         " command line height
set laststatus=2        " condition to show status line, 2=always.
set ruler               " show cursor position in status line
set showmode            " show mode in status line
set showcmd             " show partial commands in status line
" set statusline=%r%h%w\ %([%{&ff}]%)%(:%y%)%(:[%{&fenc}]%)\ BUFF[%1.20n]%=%1.7l,%1.7c\ \ [%p%%]
" shows: filename, position, eof, syntax, encoding, format
set statusline=%-3.3n\ %f\ %r%#Error#%m%#Statusline#\ (%l/%L,\ %c)\ %P%=%h%w\ %y\ [%{&encoding}:%{&fileformat}]\ 

" gvim settings --------------------------------------------------------

set guioptions-=T" Disable toolbar icons
set guifont=Terminus\ 8 " backslash spaces (e.g. Bitstream\ Vera\ Sans\ 8)
"set lines=36
"set columns=118


" tabs and indenting ---------------------------------------------------

set expandtab           " insert spaces instead of tabs
set tabstop=4           " n space tab width
set shiftwidth=4        " allows the use of < and > for VISUAL indenting
set softtabstop=4       " counts n spaces when DELETE or BCKSPCE is used
set smarttab            " set s according to shiftwidth
set autoindent          " auto indents next new line
set smartindent         " intelligent indenting -- DEPRECATED by cindent
set nocindent           " set C style indenting off, I don't write C!


" searching ------------------------------------------------------------

set hlsearch            " highlight all search results
set incsearch           " increment search
set ignorecase          " case-insensitive search
set smartcase           " uppercase causes case-sensitive search
set wrapscan            " searches wrap back to the top of file

" hotkeys --------------------------------------------------------------

" typo corrections
nmap q: :q

" enter ex mode with a semi-colon too
nnoremap ; :
vnoremap ; :

" Ctrl-s to save
inoremap  :wa
nnoremap  :w

" F2 selects all
nnoremap  ggVG      

" F3 toggles wordwrap
nnoremap  :set invwrap wrap?

" F5 toggles paste mode
set pastetoggle=

" F5 toggles spell checking
map  :setlocal spell! spelllang=en_ca
imap  :setlocal spell! spelllang=en_ca

" strip ^M linebreaks from dos formatted files
map M :%s/$//g


" firefox style tabbing ------------------------------------------------

nmap  :tabnew
nmap  :close
map  gT
map  gt
map  1gt
map  2gt
map  3gt
map  4gt
map  5gt
map  6gt
map  7gt
map  8gt
map  9gt
map  10gt


" highlight extra whitespace and tabs ----------------------------------

"highlight RedundantSpaces ctermbg=red guibg=red`
"match RedundantSpaces /\s\+$\| \+\ze\t\|\t/


" autocmd rules --------------------------------------------------------

if has("autocmd")
    au BufRead,BufNewFile PKGBUILD set ft=sh
    autocmd BufRead *.txt set tw=78     " limit width to n cols for txt files
    autocmd BufRead /tmp/mutt-* set tw=72 spell " limit width and spellcheck
    " go to last cursor position
    autocmd BufReadPost * if line("'\"")>0 && line("'\"")<=line("$")|exe "normal g`\""|endif
    " When editing a file, always jump to the last cursor position
    autocmd BufReadPost *
    \ if line("'\"") > 0 && line ("'\"") <= line("$") |
    \   exe "normal! g'\"" |
    \ endif

    " experimental stuff
    au FileType css setlocal ofu=csscomplete#CompleteCSS    " ala phrak

endif