-
Notifications
You must be signed in to change notification settings - Fork 4
/
diff.vim
40 lines (37 loc) · 943 Bytes
/
diff.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
vim9script
# nnoremap <silent> ]x :call diff#NextChange()<CR>
# nnoremap <silent> [x :call diff#PrevChange()<CR>
export def NextChange()
if !&diff
return
endif
var line = line('.')
if diff_hlID(line, col('.')) == 28
line += 1
endif
while line <= line('$')
var change_pos = filter(range(1, len(getline(line))), 'diff_hlID(line, v:val) == 28')
if !empty(change_pos)
cursor(line, change_pos[0])
return
endif
line += 1
endwhile
enddef
export def PrevChange()
if !&diff
return
endif
var line = line('.')
if diff_hlID(line, col('.')) == 28
line -= 1
endif
while line > 1
var change_pos = filter(range(1, len(getline(line))), 'diff_hlID(line, v:val) == 28')
if !empty(change_pos)
cursor(line, change_pos[0])
return
endif
line -= 1
endwhile
enddef