Vimdiff

Created Sunday 08 June 2014

http://vimdoc.sourceforge.net/htmldoc/diff.html
http://amjith.blogspot.co.il/2008/08/quick-and-dirty-vimdiff-tutorial.html
http://www.rosipov.com/blog/use-vimdiff-as-git-mergetool/
http://stackoverflow.com/questions/14904644/how-to-use-vimdiff
http://ashishgrover.com/effective-vimdiff/
http://vim.wikia.com/wiki/Ignore_white_space_in_vimdiff

Show only diff lines
https://groups.google.com/forum/#!topic/vim_use/mE7Z5zC_9tw
:h 'diffopt'
:h fold-diff
:set diffopt=filler,context:0,icase,iwhite

Diff current window
:diffthis

Diff off for the current window
:diffoff

Diff off for the current window and in all windows in the current tab
:diffoff!

Ignore whitespace
:set diffopt+=iwhite

Ignore case
:set diffopt+=icase

Set wrap (per file)
:set wrap

Counting the number of differences/current diff
http://stackoverflow.com/questions/11046475/vimdiff-displaying-the-total-number-of-changes
function! CountDiffs()
let winview = winsaveview()
let num_diffs = 0
if &diff
let pos = getpos(".")
keepj sil exe 'normal! G'
let lnum = 1
let moved = 1
while moved
let startl = line(".")
keepj sil exe 'normal! [c'
let moved = line(".") - startl
if moved
let num_diffs+=1
endif
endwhile
call winrestview(winview)
call setpos(".",pos)
endif
return num_diffs
endfunction

function! CurrentDiff()
if &diff
let num_diff = 0
let winview = winsaveview()
let pos = getpos(".")
let moved = 1
while moved
let startl = line(".")
keepj sil exe 'normal! [c'
let moved = line(".") - startl
if moved
let num_diff+=1
endif
endwhile
call winrestview(winview)
call setpos(".",pos)
return num_diff
endif
endfunction



Backlinks: