1. Ollie Rutherfurd
  2. dotvim


dotvim / vimrc

set nocompatible                " drop vi compatability

call pathogen#infect()

set backspace=indent,eol,start  " backspace over everything
set ruler                       " always show ruler
set ls=2                        " always show status
set statusline=%<%f%(\ %h%m%r%w%)\ %y%=%l,%c%V\ of\ %L\ [%06.6b:0x%05.5B]\ %P
set showmatch                   " show matching paren, bracket, etc...
set showcmd                     " show commands as entered

set enc=utf-8                   " utf-8 default encoding

set t_Co=256                    " 256 colors in terminal

" no flashing or beeping
set noerrorbells
set vb t_vb=

set number                      " line numbering - I go back and forth on it
"set autochdir                   " switch to directory of file when opening
set title                       " set terminal title

set tabstop=4                   " default to tab and indent of 4
set shiftwidth=4
set shiftround
" don't outdent hashes
inoremap # X#

set textwidth=79                " line length
set colorcolumn=+1              " otherwise, imma never gonna see it

" prefer unix over windows over os9 formats
set fileformats=unix,dos,mac

set list                        " display whitespace chars
set listchars=tab:>-,trail:.,precedes:@,extends:>
" set listchars=tab:▸›,eol:¬,trail:∘,precedes:«,extends:»,
set listchars=tab:▸\ ,eol,trail:∘,precedes:«,extends:»,
set showbreak=
set nobackup    " don't make backups
set writebackup " equivlent to jEdit's two-stage save

set ignorecase                  " by default when searching
set nohlsearch
set incsearch
set smartcase
set infercase

set joinspaces  " 2 spaces after '.', '?', and '!'

set scrolloff=3     " scroll when 3 lines from top or bottom
set splitbelow
set splitright

syntax on           " syntax highlighting on
if has("gui_running")
    colorscheme jellybeans
    if has("gui_macvim")
      set guifont=Menlo:h12
      colorscheme bclear
      set guifont=Ubuntu\ Mono\ 12
    colorscheme delek

" wild menu (completion) settings {{{
set wildmenu    " enhanced display of completion
set wildchar=<TAB>
set wildmode=list:full
set wildignore=*.pyc,*.class,*~             " python, java, & backup
set wildignore+=*.diff,*.orig,*.marks       " misc
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*   " vcs
set wildignore+=*/env/*                     " python virtualenv
set wildignore+=*.sw?                       " vim swap files
" }}}

let g:netrw_hide=1
let g:netrw_list_hide='.*\.py[oc]$,.*\.swp$'

" remap k,j for screenlines vs physical lines
nnoremap k gk
nnoremap j gj
nnoremap gk k
nnoremap gj j

map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
map <A-PageDown> <C-W>w
map <A-PageUp> <C-W>W

map <silent> <C-l> :nohlsearch<CR>
" Open a Quickfix window for the last search
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>'

map <C-o> :Explore!<CR>

" tab navigation (next tab) with alt left / alt right arrow keys
nnoremap  <a-right>  gt
nnoremap  <a-left>   gT

" highlight useless whitespace
highlight RedundantWhitespace ctermbg=red guibg=red
match RedundantWhitespace /\s\+$\| \+\ze\t/

" Enable filetype plugins and indention
filetype on
filetype plugin on

" smart indent, if there is no plugin indent file
set smartindent

autocmd BufRead,BufNewFile *.go set ft=go
autocmd BufRead,BufNewFile *.vm  set ft=velocity

autocmd! BufRead,BufNewFile *.moin
    \ if getline(1) =~ '^@@ Syntax: 1\.5$' | setf moin1_5
    \ | else | setf moin1_6 | endif

" autodect simple defects tickets (http://syncwith.us/sd/)
au BufRead,BufNewFile *
    \ if getline(1) =~ '\(required ticket metadata\)\|\(errors in this ticket\)' |
    \   setf sdticket |
    \ endif

autocmd FileType python setlocal et sw=4 ts=4
\ formatoptions+=croq softtabstop=4 smartindent
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
let python_highlight_all=1

fun! s:SelectHTML()
  let n =1
  while n < 50 && n < line("$")
    " check for jinja
    if getline(n) =~ '{%\s*\(extends\|block\|macro\|set\|if\|for\|include\|trans\)\>'
      set ft=htmljinja
    let n = n + 1
  set ft=html

autocmd BufNewFile,BufRead *.html,*.htm call s:SelectHTML()
autocmd BufNewFile,BufRead *.t set filetype=cram

autocmd FileType css setlocal tw=0 ts=2 sw=2 et sts=2 omnifunc=csscomplete#CompleteCSS
autocmd FileType html setlocal tw=0 ts=2 sw=2 et sts=2 omnifunc=htmlcomplete#CompleteTags
autocmd FileType htmljinja setlocal tw=0 ts=2 sw=2 et sts=2
autocmd FileType java setlocal et ts=4 sw=4 sts=4
autocmd FileType javascript setlocal et tw=0 ts=2 sw=2 sts=2 omnifunc=javascriptcomplete#CompleteJS
autocmd FileType go setlocal noet ts=8 sw=8 sts=8 nolist
autocmd FileType python setlocal et tw=0 ts=4 sw=4 sts=4 omnifunc=pythoncomplete#Complete
autocmd FileType sdticket setlocal tw=68
autocmd FileType velocity setlocal tw=0 ts=2 sw=2 et sts=2
autocmd FileType xml setlocal ts=2 sw=2 et sts=2

" use ack instead of grep
set grepprg=ack\ --column
set grepformat=%f:%l:%c:%m

" don't want to hear about not having ruby
let g:LustyExplorerSuppressRubyWarning = 1

" the nearest ancestor that contains one of these directories or files:
" .git, .hg, .bzr, _darcs
let g:ctrlp_working_path_mode = 2

" Rainbow (parens) {{{
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" }}}

set hidden

nnoremap <F5> :GundoToggle<CR>
nnoremap <leader>f :NERDTreeToggle<CR>

nnoremap <leader>ev <c-w>v:edit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>

" :mode=vim:noTabs=true:
" vim: set et ts=2 sw=2: