Skip to content

Instantly share code, notes, and snippets.

@hotoo
Created August 29, 2010 22:55
Show Gist options
  • Select an option

  • Save hotoo/556783 to your computer and use it in GitHub Desktop.

Select an option

Save hotoo/556783 to your computer and use it in GitHub Desktop.
function! Jump2NextDiffText(dir)
if a:dir=="prev"
exec "normal [c"
elseif a:dir=="next"
exec "normal ]c"
endif
if synIDattr(diff_hlID(".", col(".")), "name")=="DiffChange"
let line=line(".")
let cols=col("$")-1
let idx=1
while idx<=cols
if synIDattr(diff_hlID(line, idx), "name")=="DiffText"
call setpos(".", [0,line,idx])
echo line.",".idx.",".cols
break
else
let idx = idx+1
endif
endwhile
endif
endfunction
if &diff
nmap <F7> :call Jump2PrevDiffText("prev")<cr>
nmap <F8> :call Jump2NextDiffText("next")<cr>
else
map <F7> :cp<cr>
map <F8> :cn<cr>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment