I use the solution provided here, reproduced below:

function! s:DiffWithSaved()
  let filetype=&ft
  vnew | r # | normal! 1Gdd
  exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
com! DiffSaved call s:DiffWithSaved()

to individually check the diff of the buffer that currently has the cursor/focus with its earlier saved version on disk. To check the diff of a different buffer, I navigate to that buffer after giving a :q to exit the current diff and repeat :DiffSaved on that new buffer.

Can this process be automated so that a single command can be issued that automatically only does a DiffSaved for buffers that have diverged from the saved version on disk during a long editing session? Is there any easy way to navigate the various diffs that would be displayed (Quickfix list, or something similar)?

  • 1
    Not sure about quickfix, but you probably have to open each pair of diffed files in it's own tab, since they're local to tab-pages. If there were a way to figure out the set of divergent files (there probably is), something like for file in diverged | execute 'tab sbuffer' file | DiffSaved | endfor might work.
    – D. Ben Knoble
    Aug 29 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.