""""""" "" Remove Unwanted Bundles """"""""""""""""""""""""""""""""""""""""""""""""""" " We use our own powerline install UnBundle 'bling/vim-airline' " Great, but is slow when you work through tunnels, which I do a LOT. UnBundle 'airblade/vim-gitgutter' " This is not a fantastic idea, and is slow when working through tunnels. UnBundle 'myusuf3/numbers.vim' " Never go used to this UnBundle 'Lokaltog/vim-easymotion' " Don't care about gvim... yet. UnBundle 'godlygeek/csapprox' if has("autocmd") " Show trailing white space autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@ q :ccl:lcl autocmd FileType qf nnoremap o " QuickFix - Global remaps: " - `` and `\` for previous and next location entry " - unmaps when qf buffer is closed. autocmd BufWinEnter quickfix \ setlocal nocursorline | \ let g:qfix_win = bufnr("$") | \ call MapQfPrevNext() autocmd BufWinLeave * \ if exists("g:qfix_win") && expand("") == g:qfix_win | \ unlet! g:qfix_win | \ call UnmapQfPrefNext() | \ endif " QuickFix - Open window after any grep invocation (Glog and Ggrep) autocmd QuickFixCmdPost *grep* cwindow | \ setlocal nocursorline | \ let g:qfix_win = bufnr("$") | \ call MapQfPrevNext() " Fugitive - Go up to previous tree object while exploring git tree with '..' autocmd User fugitive \ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' | \ nnoremap .. :edit %:h | \ endif " Fugitive - Delete buffers when they are not active autocmd BufReadPost fugitive://* set bufhidden=delete " PHP - Offline docs, manpage-style, using `K`. " - needs pman installed through PEAR: `pear install doc.php.net/pman` if executable('pman') autocmd FileType php set keywordprg=pman endif endif """""""" "" Tabs and Text Formatting """""""""""""""""""""""""""""""""""""""""""""""""""""" set tabstop=2 " actual tab press distance set shiftround " indent to nearest tabstops set shiftwidth=2 " amount to indent with > and < set smarttab " backspace tabs where appropriate even if spaces set softtabstop=2 " let backspace delete by indents set textwidth=80 " try to keep text within 80 characters set colorcolumn=+1 " mark out the limits of the textwidth set fillchars=fold:. """""""" "" UI - Colours """""""""""""""""""""""""""""""""""""""""""""""""""""" set t_Co=16 " set colour for folded lines highlight Folded term=none cterm=none ctermfg=darkred ctermbg=none " show trailing white space highlight ExtraWhitespace ctermfg=red ctermbg=red guifg=red guibg=red " reverse indent guides highlighting highlight IndentGuidesOdd ctermbg=darkgrey highlight IndentGuidesEven ctermbg=black """""""" "" UI - Statusline (now using powerline) """""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""" "" UI - Code Folding """""""""""""""""""""""""""""""""""""""""""""""""""""""" set foldmethod=indent set foldlevel=10 set foldtext=FoldText() """""""" "" Key Remaps """""""""""""""""""""""""""""""""""""""""""""""""""""""" " More convenient escape inoremap kj inoremap jk " Add extra lines up and down nnoremap j ok nnoremap k Oj " Edit .vimrc "nnoremap v :e $MYVIMRC " Clear trailing white space nnoremap $ :%s/\s\+$//g " Convert tabs to spaces nnoremap :%s// /g " Space as a Folding toggle in normal mode. nnoremap @=(foldlevel('.')?'za':"\") " Backspace to clear current search (and stop highlighting) nnoremap :call ClearSearch() nnoremap n :set number! nnoremap w :set wrap! " Toggle paste mode - no autoindenting of pasted material nnoremap p :set paste! paste? " Toggle visible whitespace characters nnoremap l :set list! " Toggle keyboard layout nnoremap :call CycleKeymap() " Toggle scrollbind for moving multiple splits in sync together nnoremap sb :set scrollbind! scrollbind? " Toggle mouse support. "nnoremap m :call ToggleMouse() " Toggle NERDTree file browser nnoremap d :NERDTreeToggle " Toggle Commenting out lines with NERDCommenter nnoremap , :call NERDComment("n", "toggle") vnoremap , :call NERDComment("x", "toggle") " Git commands with Fugitive nnoremap gc :Gcommit -v "nnoremap gl :Glog nnoremap gap :Git add -p " Function definition jumping with CtrlP's Funky plugin nnoremap :CtrlPFunky """""""" "" Key Remaps - Movement and Windows """""""""""""""""""""""""""""""""""""""""""""""""""""""" " jump to beginning and end of line easier nmap H ^ nmap L $ vmap H ^ vmap L $ " Smart way to move between windows "nnoremap j "nnoremap k "nnoremap h "nnoremap l " mapping to make movements operate on 1 screen line in wrap mode "onoremap j ScreenMovement("j") "onoremap k ScreenMovement("k") "onoremap 0 ScreenMovement("0") "onoremap ^ ScreenMovement("^") "onoremap $ ScreenMovement("$") "nnoremap j ScreenMovement("j") "nnoremap k ScreenMovement("k") "nnoremap 0 ScreenMovement("0") "nnoremap ^ ScreenMovement("^") "nnoremap $ ScreenMovement("$") "xnoremap j ScreenMovement("j") "xnoremap k ScreenMovement("k") "xnoremap 0 ScreenMovement("0") "xnoremap ^ ScreenMovement("^") "xnoremap $ ScreenMovement("$") """""""" "" Plugin options """""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""" Powerline set rtp+=~/dotfiles/powerline/powerline/powerline/bindings/vim set noshowmode " don't show e.g. --INSERT-- since we're using powerline """"""""" Tagbar let g:tagbar_autoclose = 1 " close sidebar after we go to selection """"""""" Indent Guides let g:indent_guides_auto_colors = 0 let g:indent_guides_guide_size = 2 """"""""" Syntastic let g:syntastic_auto_jump = 1 """"""""" CtrlP "let g:ctrlp_working_path_mode = 'rw' let's try out ra let g:ctrlp_extensions = ['funky'] """"""""" Vdebug let g:vdebug_options = { \ 'break_on_open' : 0, \ 'watch_window_style' : 'compact', \ 'path_maps' : {"/usr": "/jails/alcatraz/usr"} \ } """"""""" Vim Markdown let g:vim_markdown_folding_disabled = 1 """"""""" Sparkup let g:sparkupNextMapping = 'n' " resolve conflict with vim-multiple-cursors """""""" "" Functions """""""""""""""""""""""""""""""""""""""""""""""""""""""" function! FoldText() let line = getline(v:foldstart) let indent = indent(v:foldstart) let indentOnly = strpart(line, 0, indent-1) let linecount = v:foldend+1 - v:foldstart let foldtext = '+'.indentOnly.'... ('.linecount.' More lines)' return foldtext endfunction function! ToggleMouse() if &mouse == 'a' set mouse= echo "Mouse usage disabled" else set mouse=a echo "Mouse usage enabled" endif endfunction function! ScreenMovement(movement) if &wrap return "g" . a:movement else return a:movement endif endfunction function! ClearSearch() if (@/ != "") let @/="" redraw endif endfunction function! CycleKeymap() if has('keymap') if (&keymap == '') set keymap=colemak echo "Colemak keymap selected" elseif (&keymap == 'colemak') set keymap=dvorak echo "Dvorak keymap selected" else set keymap= echo "Qwerty keymap selected" endif else echo "Keymaps not supported" endif endfunction function! MapQfPrevNext() exec "nmap :cprev" exec "nmap :cnext" endfunction function! UnmapQfPrefNext() exec "nunmap " exec "nunmap " endfunction