comparison vim/vimrc @ 303:01ec865443b6

Update NERDTree macros and tweak more Vim stuff.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 26 Jun 2015 13:54:24 -0700
parents 8bc056d80c39
children 50fbd059a6a1 5b7acab16766
comparison
equal deleted inserted replaced
302:cd3246751ccf 303:01ec865443b6
435 nnoremap <silent> <C-p> :CtrlP<cr> 435 nnoremap <silent> <C-p> :CtrlP<cr>
436 nnoremap <silent> <C-o> :CtrlPBuffer<cr> 436 nnoremap <silent> <C-o> :CtrlPBuffer<cr>
437 nnoremap <silent> <C-u> :CtrlPTag<cr> 437 nnoremap <silent> <C-u> :CtrlPTag<cr>
438 nnoremap <silent> <C-y> :CtrlPQuickfix<cr> 438 nnoremap <silent> <C-y> :CtrlPQuickfix<cr>
439 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr> 439 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
440 nnoremap <silent> <F9> :CtrlPBookmarkDir<cr> 440 nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
441 441
442 " Switch between FR and US keyboard layouts. 442 " Switch between FR and US keyboard layouts.
443 nnoremap <C-l>f :setlocal keymap=french<cr> 443 nnoremap <C-l>f :setlocal keymap=french<cr>
444 nnoremap <C-l>u :setlocal keymap=<cr> 444 nnoremap <C-l>u :setlocal keymap=<cr>
445 445
452 " Use sane regexes. 452 " Use sane regexes.
453 nnoremap / /\v 453 nnoremap / /\v
454 vnoremap / /\v 454 vnoremap / /\v
455 455
456 " Next/previous quickfix and location messages. 456 " Next/previous quickfix and location messages.
457 " This is meant to be similar to ]c and [c for the diff navigation.
457 nnoremap ]q :cnext<cr>zvzz 458 nnoremap ]q :cnext<cr>zvzz
458 nnoremap [q :cprevious<cr>zvzz 459 nnoremap [q :cprevious<cr>zvzz
459 nnoremap ]l :lnext<cr>zvzz 460 nnoremap ]l :lnext<cr>zvzz
460 nnoremap [l :lprevious<cr>zvzz 461 nnoremap [l :lprevious<cr>zvzz
461 462
462 " Same with change list. 463 " Same with change list.
463 nnoremap ]] g,zz 464 nnoremap ]] g,zz
464 nnoremap [[ g;zz 465 nnoremap [[ g;zz
465 466
466 " Same with diff list. 467 " Make the diff navigation also center things.
467 nnoremap ]c ]czvzz 468 nnoremap ]c ]czvzz
468 nnoremap [c [czvzz 469 nnoremap [c [czvzz
469 470
470 " Quick search and replace. 471 " Quick search and replace.
471 function! s:VSetSearch() 472 function! s:VSetSearch()
480 nnoremap <leader>fa :vimgrep /<C-R><C-W>/ 481 nnoremap <leader>fa :vimgrep /<C-R><C-W>/
481 vnoremap <leader>fa "zy:vimgrep /<C-R>z/ 482 vnoremap <leader>fa "zy:vimgrep /<C-R>z/
482 483
483 " Jump to tags by keeping things better in view. Option for jumping to a tag 484 " Jump to tags by keeping things better in view. Option for jumping to a tag
484 " in a split window where everything is folded except what you need to see. 485 " in a split window where everything is folded except what you need to see.
485 function! JumpToTag() 486 " Note that if a tag search yield multiple possible results, we will still run
486 execute "normal! \<c-]>zvzz" 487 " some of that `zvzz` stuff, but that's OK, the main point is to not mess up
487 endfunction 488 " the result selection window either.
488 function! JumpToTagInSplit() 489 nnoremap <c-]> <c-]>zvzz
489 execute "normal! \<c-w>v\<c-]>zMzvzz" 490 nnoremap <c-\> <c-w>v<c-]>zMzvzz
490 endfunction 491 nnoremap <F9> :tprevious
491 nnoremap <c-]> :silent! call JumpToTag()<cr> 492 nnoremap <F10> :tnext
492 nnoremap <c-\> :silent! call JumpToTagInSplit()<cr>
493 493
494 " Keep search matches in the middle of the window. 494 " Keep search matches in the middle of the window.
495 nnoremap n nzvzz 495 nnoremap n nzvzz
496 nnoremap N Nzvzz 496 nnoremap N Nzvzz
497 497
632 execute 'lcd!' fnameescape(l:root) 632 execute 'lcd!' fnameescape(l:root)
633 endif 633 endif
634 endfunction 634 endfunction
635 635
636 function! s:ToggleNERDTree() abort 636 function! s:ToggleNERDTree() abort
637 let l:was_open = nerdtree#isTreeOpen()
638 NERDTreeToggle 637 NERDTreeToggle
639 if !l:was_open 638 endfunction
639
640 function! s:FindInNERDTree() abort
641 if !g:NERDTree.IsOpen() || getbufvar('%', 'NERDTreeType') == ''
642 " If we're not in the NERDTree window, switch to it and find the
643 " current file in it.
644 NERDTreeFind
645 normal zz
646 else
647 " We're in the NERDTree window, go back to the previous one.
640 wincmd p 648 wincmd p
641 NERDTreeCWD
642 wincmd p
643 NERDTreeFind
644 endif
645 endfunction
646
647 function! s:FindInNERDTree() abort
648 if !nerdtree#isTreeOpen()
649 call s:ToggleNERDTree()
650 else
651 if getbufvar('%', 'NERDTreeType') != ''
652 wincmd p
653 else
654 NERDTreeFind
655 endif
656 endif 649 endif
657 endfunction 650 endfunction
658 651
659 " }}} 652 " }}}
660 653