" vim:cc=79,39 " make vim unusable for anyone else " from the get-go, we assume version >= 703 set nocompatible " screw vi " hacks {{{1 if has('multi_byte') scriptencoding utf-8 " allow it in this script set termencoding=utf-8 " and this terminal supports it set encoding=utf-8 " and the default file is in it endif " awful things if has("win32") let msys='/MinGW/msys/1.0/bin' let &shell=msys.'/bash.exe' set shellcmdflag=-c set shellxquote=\" set shellslash " assume directory structure: " something/anything/.vimrc " this was passed to vim by the -u switch " something/vim/ " something/vim/after let $MYVIMRC=expand('') let rcvim=expand(':p:h:h').'/vim' if !exists('win32_once') let win32_once=1 let $PATH.=';'.msys let &runtimepath=rcvim.','.&runtimepath.','.rcvim.'/after' endif else let rcvim='~/.vim' endif let &backupdir=rcvim.'/backup' " stash tilde files elsewhere " the double slash at the end dumps the path of the file for uniqueness let &directory=rcvim.'/swp//' " stash swap files too try | call mkdir(&backupdir, "p") | catch /E739/ | endtry try | call mkdir(&directory, "p") | catch /E739/ | endtry if (&term =~ "^xterm") " enable colors on any xterm let &t_Co=256 let &t_AF="\e[38;5;%dm" let &t_AB="\e[48;5;%dm" endif " main config {{{1 if has('syntax') syntax enable " required for folding as well set hlsearch " highlight search results endif if has('gui_running') set guioptions-=M " skip loading $VIMRUNTIME/menu.vim set guioptions-=m " hide menu which isn't loaded anyway set guioptions-=T " hide toolbar set guioptions-=r " hide scrollbar set guifont=Consolas:h9 set columns=84 set lines=36 cd $HOME " might not be ideal... endif try | colorscheme Tomorrow-Night | catch /E185/ | endtry if has('title') | set title | endif " terminal title set history=512 " command lines to remember set colorcolumn=79 set number " lines set ruler " write out the cursor position set lazyredraw " when executing macros, untyped things set shortmess=atI " be less verbose and shut up vim set suffixes=.bak,~,.swp,.o,.log,.out " lower tab-completion priority set noerrorbells visualbell t_vb= " disable bells set scrolloff=3 " row context during scrolling set sidescrolloff=2 " col context during scrolling set incsearch " show first search result as we type set ignorecase " insensitive searching set smartcase " except when uppercase is used set infercase " use existing case when ins-completing set foldmethod=marker set foldlevelstart=99 " start with everything unfolded let c_syntax_for_h=1 " use C highlighting for .h files set nowrap " word wrapping is pretty weak in vim set ffs=unix,dos " ffs indeed set tabstop=8 shiftwidth=8 smarttab " 8 space tabs set diffopt+=iwhite " ignore whitespace in diff command if 0 set autoindent " when creating newline, use same indent if has('smartindent') set smartindent " automatic indents with a lot of stuff endif endif " it's really just annoying though " autocmd {{{1 fu! TabFour() setlocal tabstop=8 shiftwidth=4 expandtab softtabstop=4 endf fu! TabTwo() setlocal tabstop=2 shiftwidth=2 expandtab endf if has('autocmd') augroup tabs " 4 spaces as tabs for various languages au! au FileType bash,sh,zsh,mk,awk,python,pyrex,lua,vim call TabFour() au BufRead,BufNewFile *.json call TabFour() au BufRead,BufNewFile PKGBUILD call TabTwo() au FileType ruby call TabTwo() augroup END augroup nobells " good lord vim you are archaic au! au GUIEnter * set vb t_vb= augroup END augroup reload " this is a bit annoying on windows au! au BufWritePost .vimrc,_vimrc,vimrc so $MYVIMRC augroup END fu! ResCur() " attempt to preserve cursor position if line("'\"") > 1 && line("'\"") <= line("$") normal! g`" return 1 endif endf augroup resCur au! au BufWinEnter * call ResCur() augroup END endif " keys/binds {{{1 set backspace=eol,start,indent " make backspace useful " tab completion in command-line if has('wildmenu') | set wildmenu | endif " easy indent/unindent nn >> nn << " indentation without ending selection vn >gv vn J "nn dd " oh wait, terminals don't do that... fu! Inn(q) " bind both normal and insert modes let args=split(a:q, '^\s*\(<[^>]\+>\s\+\)\+\zs') exec 'nn '.args[0].' '.args[1] exec 'ino '.args[0].' '.args[1] endf com! -nargs=+ Inn call Inn() Inn :w Inn :e Inn :bd Inn :w! Inn :e! Inn :bd! Inn :wall Inn :tab ball Inn :qall Inn :qall! " np++ habits Inn Inn Inn :m-2 Inn :m+1 Inn :tabm -1 Inn :tabm +1 " hide search highlighting Inn :nohls " rebind annoying things " reflow text nn Q gq " split lines (opposite of J) nn K ik$ vn K " follow tag nn " delete line nn D dd " this frees up x and X for use if you like set =[3;2~ Inn X " unfollow your leaders "ino " this doesn't workkkkkkkkk nn p "0p nn P "0P nn e :tabe nn d :cd %:p:h:pwd nn . @: "nn ? :exec getline(".") nn , :Tab /,\zs "nn x :system('chmod +x %') | e " nn , :Tab /,\zs nn s :call SyntaxAttr() nn 1 :colo property nn 2 :colo clearance nn 3 :colo Tomorrow-Night " misc {{{1 set list listchars=tab:»·,trail:·,extends:…,nbsp:‗ " including this in case i'm on a _really_ bad terminal: "set list listchars=tab:>-,trail:.,extends:>,nbsp:_ try | execute pathogen#infect() | catch /E117/ | endtry