Source

dotfiles / vimrc

Full commit
David Wolever 41ddc32 
David Wolever da6f933 
David Wolever 41ddc32 



David Wolever da6f933 
David Wolever 41ddc32 

David Wolever 37dd67f 
























David Wolever 41ddc32 



David Wolever 3e9d8c2 
David Wolever f094bb7 

David Wolever 7fcba78 

David Wolever 50cbf14 
David Wolever da6f933 


David Wolever 41ddc32 
David Wolever 50cbf14 
David Wolever da6f933 
David Wolever 369ef22 


David Wolever 606e510 

David Wolever 41ddc32 

David Wolever dd3fc79 
David Wolever e76cb48 


David Wolever 41ddc32 
David Wolever 756ffc8 
David Wolever da6f933 
David Wolever 41ddc32 

David Wolever 50cbf14 



David Wolever 41ddc32 



David Wolever 3e9d8c2 
David Wolever 5e6582d 
David Wolever dd3fc79 
David Wolever 0ced275 
David Wolever e76cb48 

David Wolever b3eaf64 
David Wolever dd3fc79 
David Wolever 50cbf14 
David Wolever 41ddc32 

David Wolever 50cbf14 
David Wolever 5e6582d 



David Wolever 69b25c7 
David Wolever c7c6cef 
David Wolever dd3fc79 

David Wolever 1915b87 
David Wolever 5e6582d 
David Wolever 3e9d8c2 
David Wolever 5e6582d 

David Wolever 7b1ce91 





David Wolever 3d2756f 

David Wolever 7b1ce91 
David Wolever 41ddc32 

David Wolever 61f683c 






David Wolever 5e6582d 


David Wolever 41ddc32 

David Wolever 5e6582d 


David Wolever 41ddc32 
David Wolever 5e6582d 


David Wolever 606e510 
David Wolever 9212fb6 
David Wolever 5e6582d 
David Wolever 606e510 





David Wolever 41ddc32 
David Wolever 5e6582d 

David Wolever 69b25c7 
David Wolever 5e6582d 
David Wolever da6f933 


David Wolever fe82f96 



David Wolever da6f933 
David Wolever 3e9d8c2 
David Wolever 76009d0 



David Wolever 6be3ab8 
David Wolever a6c1c2c 
David Wolever 606e510 


David Wolever 5e6582d 
David Wolever 41ddc32 
David Wolever 5e6582d 

David Wolever 41ddc32 

David Wolever e76cb48 
David Wolever 41ddc32 


David Wolever 50cbf14 
















David Wolever 41ddc32 

David Wolever 50cbf14 

David Wolever 19eb700 
David Wolever 77aaea0 



David Wolever 50cbf14 




David Wolever da6f933 



David Wolever 463d168 
David Wolever c7c6cef 



David Wolever 3866fb8 
David Wolever fe82f96 
David Wolever 2465d34 





David Wolever 3866fb8 

















David Wolever dd3fc79 
David Wolever bbe4af3 
David Wolever dd3fc79 
David Wolever d3934be 











David Wolever f094bb7 



David Wolever 3e9d8c2 
David Wolever 7fcba78 


David Wolever a3a8ab8 
David Wolever 7fcba78 
David Wolever a3a8ab8 
David Wolever 5b4ba6e 
David Wolever 7fcba78 
David Wolever 756ffc8 













David Wolever 3e9d8c2 
David Wolever 756ffc8 
David Wolever 3e9d8c2 
David Wolever dedc539 








David Wolever 37dd67f 
David Wolever 463d168 
" Tab options
set tabstop=8       " When reading a file, show a tab ('\t') as 8 spaces
set softtabstop=4   " When inserting a tab (eg, pressing 'tab'), insert 4 spaces
set shiftwidth=4    " Number of spaces to indent when using '>>'
set expandtab       " Never insert an actual tab character -- always use spaces
set autoindent      " Copy indent from current line to next when enter is pressed
set history=1000    " Keep lots and lots of history
" See also: :help retab

" HardTabs([width=8]): Sets up the current buffers so that:
" - '\t' is 'widith' wide
" - '<tab>' inserts a '\t'
" - '>>' shifts one tab
fun! HardTabs(...)
    let width = (a:0 > 0? a:1 : 8)
    let &l:tabstop=width
    let &l:softtabstop=width
    let &l:shiftwidth=width
    let &l:expandtab=0
endfun

" SoftTabs([softWidth=4, [hardWidth=8]]): Sets up the current buffers so that:
" - '\t' is 'hardWidth' wide
" - '<tab>' inserts 'softWidth' spaces
" - '>>' shifts with 'softWidth' spaces
fun! SoftTabs(...)
    let softWidth = (a:0 > 0? a:1 : 4)
    let hardWidth = (a:0 > 1? a:2 : 8)
    let &l:tabstop=hardWidth
    let &l:softtabstop=softWidth
    let &l:shiftwidth=softWidth
    let &l:expandtab=1
endfun

" Searching options
set ignorecase   " Ignore case when searching
set smartcase    " See :help smartcase (trust me, it's useful)
set incsearch    " Incremental search
set hlsearch     " Highlight searches
" I use 'DW: ' to prefix lines during code review - this wraps them properly
" with 'gq'.
set comments-=b:#
set comments+=b:#\ DW\:,b:#

" Make sure that the leader is '\'
let mapleader="\\"

" Turn off highlighting when \ is pressed
map <leader>\ :noh<return>
" FuzzyFinder FTW http://www.vim.org/scripts/script.php?script_id=1984
map <leader>f :FufFile<CR>
map <leader>t :FufTag<CR>
map <leader>b :FufBuffer<CR>
map <leader>g :FufTaggedFile<CR>
map <leader>T :FufTaggedFile<CR>

" File type things
syntax enable       " Turn on syntax hilighting
filetype on         " Enable filetype detection
filetype indent on  " Enable filetype-specific indenting
filetype plugin on  " Enable filetype-specific plugins

" Use <C-A> to execute the current file (equivalent to ./$FILE)
map <C-A> :!%:p<return>

" XML, HTML and Javascript have very bad indent settings... Don't use them.
" autocmd BufEnter *.js setlocal indentexpr= " Stop auto-indenting
" autocmd BufEnter *.js setlocal nocin
" autocmd BufEnter *.js setlocal smartindent
" autocmd BufEnter *.js setlocal autoindent

" When switching to a file, enter its directory
autocmd BufEnter * :lcd %:p:h

" Miscellaneous stuff...
set backspace=indent,eol,start " Better backspacing
set ruler           " Show a ruler along the bottom of the screen
set lazyredraw      " Don't re-draw while running macros
set hid             " Can hide buffers without closing them
set shortmess=atI   " shortens messages to avoid 'press a key' prompt 
set scrolloff=3     " Always keep three lines above or below the cursor
set nocompatible    " Keep vim from trying to be 100% vi compatible
set title           " Set the window title
set showcmd         " Show (partial) command in status line.
set wildmenu        " Pretty command-line option matching
set wildmode=list:longest " Shell-style matching
set wildignore=*.bak,*.o,*.e,*~,*.pyc
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.class,.pyc
set tags=tags;/
set statusline=%f%m%r%h%w\ [%Y]\ [0x\%02.2B]%<\ %F%=%4v,%4l\ %3p%%\ of\ %L
set laststatus=2    " Always show status line
set modelines=5     " Allow modelines within 5 lines of top/bottom
" set relativenumber  " Relative jump numbers up the side

" Folding options
set foldmethod=marker

" Formatting options
"autocmd BufNewFile,BufRead * setlocal formatoptions+=cqn
set formatoptions=cqn
" c: auto-wrap comments to textwidth
" q: Allow formatting comments with 'gq'
" n: Recognized numbered lists (eg: '1. ...\n 2. ... \n')
" See also: :help fo-table, ftplugin/rst.vim
set formatlistpat=^\\s*\\(\\(\\d\\+\\\)[\\]:.)}\\t\ ]\\\)\\s*

" When editing CPython source, run their provided vimrc (setting certain useful
" things like their coding standards)
let py_source = '\(Py3k-svn\|Python-trunk\)'
let path = expand('%:p:h')
if path =~ py_source
    let path = substitute(path, '\(.*/' . py_source . '\).*', '\1', '')
    execute('source ' . path . '/Misc/Vim/vimrc')
endif

" Make p in Visual mode replace the selected text with the "" register.
vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>

" Move to the first non-whitespace character when 0 is pressed and the first
" character on the line when ^ is pressed (instead of vice-versa)
noremap 0 ^
noremap ^ 0

" Use j and k to move down and up _logical_ lines instead of line-break lines
nmap j gj
nmap k gk

" Insert a blank line below the current line
map <C-O> o<esc>k

" Remap <m-.> to next-change-location and <m-,> to previous-change-location
noremap <esc>, <c-o>
noremap<c-o>
noremap <esc>. <c-i>
noremap<c-i>

" NetRW (the file browser) stuff... Safe to ignore :)
let g:netrw_sort_sequence='[\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$,\.pyc$'
let g:netrw_keepdir=0
let g:netrw_browse_split=0

" NERD tree
" Toggle
map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>
" I often hit 'e' instead of 'o', so change the 'open explorer' from 'e' to
" 'E' (it's annoying to have an explorer open when I don't want one)
let g:NERDTreeMapOpenExpl = 'E'


" Some windowing convenience methods
map <c-h> <c-w>h
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-@> <c-w>_
map <c-space> <c-w>_

map = gt
map - gT

" Who needs arrow keys anyway?
map <right> :bn<return>
map <left> :bp<return>
map <up> :cp<return>
map <down> :cn<return>

"set t_kb=         " Fix backspace problems on some machines
"fixdel              " But this creates backspace problems on others... :(

" CSC369 stuff
let curpath = expand('%:p:h')
if curpath =~ 'CSC369/'
    " map gc (Goto Callers) to find all the places where <cword> is used
    map gc :grep -R <cword> ~/School/CSC369/src/kern/<return>
    " Setup the path so find will work
    set path=~/School/CSC369/src/**
endif

" Exchange the jumping characteristics of ' and `
nnoremap ' `
nnoremap ` '

" Faster scrolling
nnoremap <C-e> <C-e><C-e><C-e>
nnoremap <C-y> <C-y><C-y><C-y>

" Uncomment this line to use <C-N> to open a terminal
" map  :!gnome-terminal &<Enter><Enter>

colorscheme tolerable
hi Folded ctermbg=none ctermfg=White cterm=none   
hi Pmenu ctermbg=none ctermfg=White cterm=none
hi PmenuSel ctermbg=darkgrey ctermfg=White cterm=none
hi PmenuThumb ctermbg=white ctermfg=white
hi PmenuSbar ctermbg=black ctermfg=black

" Match braces just by white-bolding them, not making them cyan
hi MatchParen ctermbg=none ctermfg=white term=bold cterm=bold
set showmatch    " Show matching brackets.
set matchtime=1

if has('gui_running')
    set guioptions-=T       " no toolbar
end

if has('cmdlog')
    set cmdlogdir=~/.vimlogs/
end

" Helpful for when other people use my Vim
fun! NoCrazyBindings()
    unmap <left>
    unmap <right>
    unmap <up>
    unmap <down>
endfun

" 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).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
  \ if line("'\"") > 1 && line("'\"") <= line("$") |
  \   exe "normal! g`\"" |
  \ endif

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
		  \ | wincmd p | diffthis
endif

" Make 'grep' ignore '.svn' directories and recurse
set grepprg=grep\ -R\ --exclude='*.svn*'\ -n\ $*

" Fix a diff, making it easier to review.
" Add a blank line before each '@@ ... hunk line info ...@@' and each 'diff',
" making it easier to jump around using { and }
fun! ReviewDiff()
    let oldreg_val = getreg('d')
    let oldreg_type = getregtype('d')
    call setreg('d', '', 'V')
    g/^diff/put! d
    g/^@@/put! d
    call setreg('d', oldreg_val, oldreg_type)
endfun

if has("mouse")
    set mouse=a
endif

" Give me the option to confirm overwrites and other things without having to
" use '!'.
set confirm

" Words I can't spell
syn match Error /conneciton/
syn match Error /verticies/
syn match Error /heigth/

" Things to ignore while spell checking:
" - CamelCase words
" - URLs http://asdf.com/asdf
" - paths /asdf/adfa/dsfa
" - emails asdf@asdf.com
" - backslash-escaped characters \t \n
fun! AddSpellIgnore()
    syn match SpellIgnoreCamel /\<[A-Z][a-z]\+[A-Z].\{-}\>/ contains=@NoSpell transparent
    syn match SpellIgnorePath /[^ \t'"<>]*\/[^ \t'"<>]*/ contains=@NoSpell transparent
    syn match SpellIgnoreEmail /[a-zA-Z][^ \t]*@[^ \t]*\.[a-z]\{,3}\>/ contains=@NoSpell transparent
    syn match SpellIgnoreEscaped /\\[a-zA-Z]/ contains=@NoSpell transparent
    syn match SpellIgnoreFile /[a-zA-Z][^ \t'"<>]*\.[a-zA-Z]\+/ contains=@NoSpell transparent
    syn cluster Spell add=SpellIgnoreCamel,SpellIgnorePath
    syn cluster Spell add=SpellIgnoreEmail,SpellIgnoreEscaped, SpellIgnoreFile
endfun
" autocmd BufRead,BufNewFile * :call AddSpellIgnore()

" Don't highlight '$(...)' as an error in shell scripts
let g:is_posix = 1

" Use :Term to open a terminal
fun! Term()
   !~/bin/term  "%:p:h"
endfun
command! Term call Term()


" Enable perdy 256 color mode
" set t_Co=256