From bced2175f8fa8296d16e9ee5cf15f637cdfd4e53 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 25 Nov 2019 12:12:49 +0000 Subject: [PATCH] Add snippet for cycling hunks in current buffer. Thanks @andys8 :) Closes #667. --- README.mkd | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.mkd b/README.mkd index 7a35f32..6e7cf1f 100644 --- a/README.mkd +++ b/README.mkd @@ -519,6 +519,22 @@ Let's say, for example, you want to remove trailing whitespace from all changed ``` +#### Cycle through hunks in current buffer + +This is like `:GitGutterNextHunk` but when it gets to the last hunk in the buffer it cycles around to the first. + +```viml +function! GitGutterNextHunkCycle() + let line = line('.') + silent! GitGutterNextHunk + if line('.') == line + normal! 1G + GitGutterNextHunk + endif +endfunction +``` + + #### Cycle through hunks in all buffers You can use `:GitGutterQuickFix` to load all hunks into the quickfix list or the current window's location list.