comparison vim/vimrc @ 289:8b6ca7e40f37

Making jumping around in Vim nicer.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 20 Feb 2015 11:49:18 -0800
parents 25b672f0f6bd
children aac9b5b1f921
comparison
equal deleted inserted replaced
288:25b672f0f6bd 289:8b6ca7e40f37
453 453
454 " Use sane regexes. 454 " Use sane regexes.
455 nnoremap / /\v 455 nnoremap / /\v
456 vnoremap / /\v 456 vnoremap / /\v
457 457
458 " Next/previous quickfix and location messages.
459 nnoremap ]q :cnext<cr>zvzz
460 nnoremap [q :cprevious<cr>zvzz
461 nnoremap ]l :lnext<cr>zvzz
462 nnoremap [l :lprevious<cr>zvzz
463
464 " Same with change list.
465 nnoremap ]] g,zz
466 nnoremap [[ g;zz
467
468 " Same with diff list.
469 nnoremap ]c ]czvzz
470 nnoremap [c [czvzz
471
458 " Quick search and replace. 472 " Quick search and replace.
459 function! s:VSetSearch() 473 function! s:VSetSearch()
460 let temp = @@ 474 let temp = @@
461 norm! gvy 475 norm! gvy
462 let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') 476 let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
466 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o> 480 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o>
467 481
468 " Jump to tags by keeping things better in view. Option for jumping to a tag 482 " Jump to tags by keeping things better in view. Option for jumping to a tag
469 " in a split window where everything is folded except what you need to see. 483 " in a split window where everything is folded except what you need to see.
470 function! JumpToTag() 484 function! JumpToTag()
471 execute "normal! \<c-]>zz" 485 execute "normal! \<c-]>zvzz"
472 endfunction 486 endfunction
473 function! JumpToTagInSplit() 487 function! JumpToTagInSplit()
474 execute "normal! \<c-w>v\<c-]>zMzvzz" 488 execute "normal! \<c-w>v\<c-]>zMzvzz"
475 endfunction 489 endfunction
476 nnoremap <c-]> :silent! call JumpToTag()<cr> 490 nnoremap <c-]> :silent! call JumpToTag()<cr>
477 nnoremap <c-\> :silent! call JumpToTagInSplit()<cr> 491 nnoremap <c-\> :silent! call JumpToTagInSplit()<cr>
478 492
479 " Keep search matches in the middle of the window. 493 " Keep search matches in the middle of the window.
480 nnoremap n nzzzv 494 nnoremap n nzvzz
481 nnoremap N Nzzzv 495 nnoremap N Nzvzz
482
483 " Same when jumping around
484 nnoremap g; g;zz
485 nnoremap g, g,zz
486 496
487 " }}} 497 " }}}
488 498
489 " Folding {{{ 499 " Folding {{{
490 500