aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/diff.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-27 17:18:35 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-27 17:18:35 +1200
commit3f73517e2dd1be08af6588b3d49cf470e0fb4acd (patch)
treee0ca1e212d04029ba5e20119a702b42409c6359c /vim/autoload/diff.vim
parentMerge branch 'release/v1.61.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-3f73517e2dd1be08af6588b3d49cf470e0fb4acd.tar.gz
dotfiles-3f73517e2dd1be08af6588b3d49cf470e0fb4acd.zip
Merge branch 'release/v1.62.0'v1.62.0
* release/v1.62.0: Bump VERSION Improve diff block navigation in Vim with function Correct a comment Silence Vim diff section navigation maps Use local leader keys in Vim diff section nav maps Use search() in Vim diff section navigation maps
Diffstat (limited to 'vim/autoload/diff.vim')
-rw-r--r--vim/autoload/diff.vim29
1 files changed, 29 insertions, 0 deletions
diff --git a/vim/autoload/diff.vim b/vim/autoload/diff.vim
new file mode 100644
index 00000000..32e9333a
--- /dev/null
+++ b/vim/autoload/diff.vim
@@ -0,0 +1,29 @@
+" Move between diff block headers
+function! diff#MoveBlock(count, up, visual) abort
+
+ " Reselect visual selection
+ if a:visual
+ normal! gv
+ endif
+
+ " Flag for the number of blocks passed
+ let l:blocks = 0
+
+ " Iterate through buffer lines
+ let l:num = line('.')
+ while a:up ? l:num > 1 : l:num < line('$')
+ let l:num += a:up ? -1 : 1
+ if getline(l:num) =~# '^@@'
+ let l:blocks += 1
+ if l:blocks == a:count
+ break
+ endif
+ endif
+ endwhile
+
+ " Move to line if nonzero and not equal to the current line
+ if l:num != line('.')
+ execute 'normal '.l:num.'G'
+ endif
+
+endfunction