From 0537c6945a4ff88ab3448617224766c71fb0ff62 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 15 Jan 2014 15:36:13 +0100 Subject: [PATCH] Use [c and ]c to jump between hunks (changes). This is more consistent with Vim. --- README.mkd | 10 +++++----- plugin/gitgutter.vim | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.mkd b/README.mkd index 4df90b5..bf0d4bf 100644 --- a/README.mkd +++ b/README.mkd @@ -69,16 +69,16 @@ And you can turn line highlighting on and off (defaults to off): Furthermore you can jump between hunks: -* jump to next hunk: `]h` -* jump to previous hunk: `[h`. +* jump to next hunk (change): `]c` +* jump to previous hunk (change): `[c`. Both of those take a preceding count. -To set your own mappings for these, for example `gh` and `gH`: +To set your own mappings for these, for example `]h` and `[h`: ```viml -nmap gh GitGutterNextHunk -nmap gH GitGutterPrevHunk +nmap ]h GitGutterNextHunk +nmap [h GitGutterPrevHunk ``` When your cursor is in a hunk, you can: diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index dbaf647..4689b73 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -246,13 +246,15 @@ function! GitGutterGetHunkSummary() endfunction -nnoremap GitGutterNextHunk :execute v:count1 . "GitGutterNextHunk" -nnoremap GitGutterPrevHunk :execute v:count1 . "GitGutterPrevHunk" +nnoremap GitGutterNextHunk &diff ? ']c' : ":\execute v:count1 . 'GitGutterNextHunk'\" +nnoremap GitGutterPrevHunk &diff ? '[c' : ":\execute v:count1 . 'GitGutterPrevHunk'\" if g:gitgutter_map_keys - if !hasmapto('GitGutterNextHunk') && maparg(']h', 'n') ==# '' - nmap ]h GitGutterNextHunk - nmap [h GitGutterPrevHunk + if !hasmapto('GitGutterPrevHunk') && maparg('[c', 'n') ==# '' + nmap [c GitGutterPrevHunk + endif + if !hasmapto('GitGutterNextHunk') && maparg(']c', 'n') ==# '' + nmap ]c GitGutterNextHunk endif endif