# HG changeset patch # User Ludovic Chabant # Date 1435352064 25200 # Node ID 01ec865443b60a864138549e8625ed611c15daa8 # Parent cd3246751ccf2680a65445951dcd5240e88bfb70 Update NERDTree macros and tweak more Vim stuff. diff -r cd3246751ccf -r 01ec865443b6 vim/vimrc --- a/vim/vimrc Tue Jun 02 10:12:06 2015 -0700 +++ b/vim/vimrc Fri Jun 26 13:54:24 2015 -0700 @@ -437,7 +437,7 @@ nnoremap :CtrlPTag nnoremap :CtrlPQuickfix nnoremap :CtrlPMRUFiles -nnoremap :CtrlPBookmarkDir +nnoremap :CtrlPBookmarkDir " Switch between FR and US keyboard layouts. nnoremap f :setlocal keymap=french @@ -454,6 +454,7 @@ vnoremap / /\v " Next/previous quickfix and location messages. +" This is meant to be similar to ]c and [c for the diff navigation. nnoremap ]q :cnextzvzz nnoremap [q :cpreviouszvzz nnoremap ]l :lnextzvzz @@ -463,7 +464,7 @@ nnoremap ]] g,zz nnoremap [[ g;zz -" Same with diff list. +" Make the diff navigation also center things. nnoremap ]c ]czvzz nnoremap [c [czvzz @@ -482,14 +483,13 @@ " Jump to tags by keeping things better in view. Option for jumping to a tag " in a split window where everything is folded except what you need to see. -function! JumpToTag() - execute "normal! \zvzz" -endfunction -function! JumpToTagInSplit() - execute "normal! \v\zMzvzz" -endfunction -nnoremap :silent! call JumpToTag() -nnoremap :silent! call JumpToTagInSplit() +" Note that if a tag search yield multiple possible results, we will still run +" some of that `zvzz` stuff, but that's OK, the main point is to not mess up +" the result selection window either. +nnoremap zvzz +nnoremap vzMzvzz +nnoremap :tprevious +nnoremap :tnext " Keep search matches in the middle of the window. nnoremap n nzvzz @@ -634,25 +634,18 @@ endfunction function! s:ToggleNERDTree() abort - let l:was_open = nerdtree#isTreeOpen() NERDTreeToggle - if !l:was_open - wincmd p - NERDTreeCWD - wincmd p - NERDTreeFind - endif endfunction function! s:FindInNERDTree() abort - if !nerdtree#isTreeOpen() - call s:ToggleNERDTree() + if !g:NERDTree.IsOpen() || getbufvar('%', 'NERDTreeType') == '' + " If we're not in the NERDTree window, switch to it and find the + " current file in it. + NERDTreeFind + normal zz else - if getbufvar('%', 'NERDTreeType') != '' - wincmd p - else - NERDTreeFind - endif + " We're in the NERDTree window, go back to the previous one. + wincmd p endif endfunction