When diffing two files in Vim, is it possible to display the total number of changes? I suppose, this is equivalent to counting the number of folds, but I don’t know how to do that either.
Ideally, I would like a message which says something like “Change 1 of 12”, which would update as I cycle through the changes with ]c.
I’m having great success converting some members of my office to the wonders of Vim, but Vimdiff is a consistent bugbear.
Here is a slightly more refined solution. It uses the same technique as my previous answer to count the diffs, but it stores the first line of each hunk in a list asigned to a global variable
g:diff_hunks. Then the number of hunks below the cursor can be found by finding the position of the line number in the list. Also notice that I setnocursorbindandnoscrollbindand reset them at the end to ensure we don’t break mouse scrolling in the diff windows.The function
UpdateDiffHunks()should be updated whenever a diff buffer is modified, but I find it sufficient to map it toCursorMovedandBufEnter.The output of
DiffCount()can be used in the statusline, or tied to a command.