dotvim / vimrc

filetype off                    " for pathogen"
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set nocompatible                " drop vi compatability

set backspace=indent,eol,start  " backspace over everything
set ruler                       " always show ruler
set ls=2                        " always show status
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 hlsearch
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$'

inoremap <C-BS> <C-w>
inoremap jj <esc>

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

" like help says, logical
nnoremap Y y$

" A+arrow indents
nnoremap <A-Left> <<
nnoremap <A-Right> >>
vnoremap <A-Left> <<
vnoremap <A-Right> >>

" easier navigation between splits
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
nnoremap <A-PageDown> <C-W>w
nnoremap <A-PageUp> <C-W>W

" Copy the entire buffer into the system clipboard
map <leader>ya :%y+<CR>
" Yank a visual selection into the system clipboard
map <leader>yv :y+<CR>
map <leader>ys :y+<CR>

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

nnoremap <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/

" 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 (
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

let g:statline_show_charcode = 1

let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:syntastic_stl_format = '[%E{E 1/%e: #%fe}%B{, }%W{W 1/%w: #%fw}]'

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

" normal tab behavior if no snippet is matched
if !exists("g:snipMate")
  let g:snipMate = {}
let g:snipMate['no_match_completion_feedkeys_chars'] = "\<tab>"

" 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 <leader>h :set hlsearch!<cr>

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

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

nnoremap <leader>sp :set spell!<cr>

nnoremap <leader>n :set number!<cr>
nnoremap <leader>w :set wrap!<cr>

" :mode=vim:noTabs=true:
" vim: set et ts=2 sw=2:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.