From 935184bd1806e37c1e3319c7f7f3ae94ef5a5313 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 17 Apr 2013 11:23:11 +0200 Subject: [PATCH] Add default mappings. --- README.mkd | 14 ++++++++------ plugin/gitgutter.vim | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.mkd b/README.mkd index a36e26c..d85da70 100644 --- a/README.mkd +++ b/README.mkd @@ -53,16 +53,18 @@ And you can turn line highlighting on and off (defaults to off): * turn off with `:GitGutterLineHighlightsDisable` * toggle with `:GitGutterLineHighlightsToggle`. -Furthermore you can jump between `[count]` hunks: +Furthermore you can jump between hunks: -* jump to next hunk: `:[count]GitGutterNextHunk [count]` -* jump to previous hunk: `:[count]GitGutterPrevHunk [count]`. +* jump to next hunk: `]h` +* jump to previous hunk: `[h`. -You may want to add mappings for these if you use them often. For example: +Both of those take a preceding count. + +To set your own mappings for these, for example `gh` and `gH`: ```viml -nmap ]h :execute v:count1 . "GitGutterNextHunk" -nmap [h :execute v:count1 . "GitGutterPrevHunk" +nmap gh GitGutterNextHunk +nmap gH GitGutterPrevHunk ``` Finally, you can force vim-gitgutter to update its signs across all visible buffers with `:GitGutterAll`. diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 9cb838d..e27deb7 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -524,6 +524,14 @@ function! GitGutterGetHunks() return s:is_active() ? s:hunks : [] endfunction +nnoremap GitGutterNextHunk :execute v:count1 . "GitGutterNextHunk" +nnoremap GitGutterPrevHunk :execute v:count1 . "GitGutterPrevHunk" + +if !hasmapto('GitGutterNextHunk') && maparg(']h', 'n') ==# '' + nmap ]h GitGutterNextHunk + nmap [h GitGutterPrevHunk +endif + augroup gitgutter autocmd! if g:gitgutter_eager