mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 19:43:47 -05:00
Explain how to cycle through hunks in all buffers.
This commit is contained in:
52
README.mkd
52
README.mkd
@@ -427,6 +427,58 @@ Let's say, for example, you want to remove trailing whitespace from all changed
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Cycle through hunks in all buffers
|
||||||
|
|
||||||
|
`]c` and `[c` jump from one hunk to the next in the current buffer. You can use this code to jump to the next hunk no matter which buffer it's in.
|
||||||
|
|
||||||
|
```viml
|
||||||
|
function! NextHunkAllBuffers()
|
||||||
|
let line = line('.')
|
||||||
|
GitGutterNextHunk
|
||||||
|
if line('.') != line
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let bufnr = bufnr('')
|
||||||
|
while 1
|
||||||
|
bnext
|
||||||
|
if bufnr('') == bufnr
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
if !empty(GitGutterGetHunks())
|
||||||
|
normal! 1G
|
||||||
|
GitGutterNextHunk
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! PrevHunkAllBuffers()
|
||||||
|
let line = line('.')
|
||||||
|
GitGutterPrevHunk
|
||||||
|
if line('.') != line
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let bufnr = bufnr('')
|
||||||
|
while 1
|
||||||
|
bprevious
|
||||||
|
if bufnr('') == bufnr
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
if !empty(GitGutterGetHunks())
|
||||||
|
normal! G
|
||||||
|
GitGutterPrevHunk
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
nmap <silent> ]c :call NextHunkAllBuffers()<CR>
|
||||||
|
nmap <silent> [c :call PrevHunkAllBuffers()<CR>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### FAQ
|
### FAQ
|
||||||
|
|
||||||
> Why can't I unstage staged changes?
|
> Why can't I unstage staged changes?
|
||||||
|
|||||||
Reference in New Issue
Block a user