set nocompatible " Set syntax and highlighting syntax on "colorscheme slate "colorscheme dante colorscheme baraknew " Set default spacing "set gfn=Monaco:h12:a set ts=8 set softtabstop=2 set shiftwidth=2 set expandtab let mapleader = "," filetype off call pathogen#runtime_append_all_bundles() filetype plugin indent on " Set 'smart' things in Vim set smartcase set autoindent set smartindent set cindent set hidden set backspace=indent,eol,start set history=1000 set wildmenu set wildmode=list:longest set ruler " Some stuff for console 256 Colors set t_Co=256 set t_Sf=ESC[3%dm set t_Sb=ESC[4%dm "set t_kb= " "if v:version >= 703 "set relativenumber "set colorcolumn=81 "endif " Sources "source ~/.vim/supertab.vim "source ~/.vim/charm.vim "source ~/.vim/plugin/AppleT.vim runtime macros/matchit.vim " Completion features (TODO: Add to filetype.vim) autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete autocmd FileType python set tags+=$HOME/.vim/tags/python.ctags "autocmd FileType python set omnifunc=pythoncomplete#Complete "autocmd FileType python call SuperTabSetCompletionType("") let python_highlight_all = 1 let g:Tb_MaxSize=0 let g:Tb_MapCTabSwitchBufs = 1 let g:buftabs_only_basename = 1 "let g:buftabs_in_statusline=1 "MiniBufExplore Options "let g:miniBufExplMapWindowNavVim = 1 "let g:miniBufExplMapWindowNavArrows = 1 "let g:miniBufExplMapCTabSwitchBufs = 1 "let g:miniBufExplModSelTarget = 1 "let g:miniBufExplForceSyntaxEnable = 1 "Remappings "Open in tabs... "nnoremap gc :tabnew "nnoremap gK :tabclose "nnoremap gn gt "nnoremap gp gT nmap gt :NERDTreeToggle nnoremap gc :bdelete nnoremap gK :bdelete! nnoremap gn :bn nnoremap gp :bp nnoremap gz :pclose nnoremap gw g* nmap P op nnoremap j gj nnoremap k gk xnoremap j gj xnoremap k gk nnoremap gj nnoremap gk xnoremap gj xnoremap gk inoremap gj inoremap gk "nnoremap nnoremap ^ nnoremap $ xnoremap ^ xnoremap $ inoremap ^ inoremap $ imap set laststatus=2 set statusline=%t "tail of the filename "set statusline+=[%{&ff}] "file format "set statusline+=%h "help file flag set statusline+=\ %w "help file flag set statusline+=%r "read only flag set statusline+=%y "filetype set statusline+=\ %m "modified flag set statusline+=%= "left/right separator set statusline+=%c, "cursor column set statusline+=%l/%L "cursor line/total lines set statusline+=\ %P "percent through file " Commentary? Maybe remove these, I rarely use them " , #perl # comments map ,# :s/^/#/ " , #mako ## comments map ,% :s/^/##/ " ,/ C/C++/C#/Java // comments map ,/ :s/^/\/\// " ,< HTML comment map ,< :s/^\(.*\)$//:nohlsearch " c++ java style comments map ,* :s/^\(.*\)$/\/\* \1 \*\//:nohlsearch " Useful functions " Add capital W so I can be lazy about my shift jey if !exists(":W") command W :w endif " Save a vim session! Useful if you want to save buffer states and so on command SaveSession :mksession! ~/.vim_last_session command LoadSession :source ~/.vim_last_session " This is a quick way to edit a persistent scratch buffer for me... command ScratchOpen :e scp://barak@barakmich.com//home/barak/notes/scratch " Sudo-make-me-a-sandwich write command Wdammit :w !sudo tee % " Doesn't quite work right but can be a real savior if needed function! s:DiffWithSaved() let filetype=&ft diffthis vnew | r # | normal! 1Gdd diffthis exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype endfunction com! DiffSaved call s:DiffWithSaved() " Forget where I found this... function! Find(name) let l:_name = substitute(a:name, "\\s", "*", "g") "let l:list=system("find . -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" | perl -ne 'print \"$.\\t$_\"'") let l:list=system("find . -path \"*/.svn\" -prune -o -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" -print | perl -ne 'print \"$.\\t$_\"'") let l:num=strlen(substitute(l:list, "[^\n]", "", "g")) if l:num < 1 echo "'".a:name."' not found" return endif if l:num != 1 echo l:list let l:input=input("Which ? (=nothing)\n") if strlen(l:input)==0 return endif if strlen(substitute(l:input, "[0-9]", "", "g"))>0 echo "Not a number" return endif if l:input<1 || l:input>l:num echo "Out of range" return endif let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*") else let l:line=l:list endif let l:line=substitute(l:line, "^[^\t]*\t./", "", "") execute ":e ".l:line endfunction command! -nargs=1 Find :call Find("") " toggles the quickfix window. command -bang -nargs=? QFix call QFixToggle(0) function! QFixToggle(forced) if exists("g:qfix_win") && a:forced == 0 cclose else execute "copen " . 15 endif endfunction " used to track the quickfix window augroup QFixToggle autocmd! autocmd BufWinEnter quickfix let g:qfix_win = bufnr("$") autocmd BufWinEnter quickfix exec "nnoremap q :QFix" autocmd BufWinLeave * if exists("g:qfix_win") && expand("") == g:qfix_win | unlet! g:qfix_win | endif augroup END nnoremap qf :QFix nnoremap aw :AckWord nnoremap ac :Ack " Googley things.... function! HighlightTooLongLines() highlight def link RightMargin Error if &textwidth != 0 exec 'match RightMargin /\%<' . (&textwidth + 3) . 'v.\%>' . (&textwidth + 1) . 'v/' endif endfunction let g:google = 0 if filereadable("/usr/share/vim/google/google.vim") source /usr/share/vim/google/google.vim let g:google = 1 else if filereadable("/google/src/head/depot/eng/vim/google.vim") source /google/src/head/depot/eng/vim/google.vim let g:google = 1 else if filereadable("/home/build/public/eng/vim/google.vim") source /home/build/public/eng/vim/google.vim let g:google = 1 endif endif endif if g:google != 0 augroup filetypedetect au WinEnter,BufNewFile,BufRead * call HighlightTooLongLines() augroup END endif if filereadable("/home/build/nonconf/google3/tools/tags/gtags.vim") source /home/build/nonconf/google3/tools/tags/gtags.vim nmap :exe 'Gtlist ' . expand('') endif