Vim help suggests a nice command to show a side-by-side diff of the current buffer since the last save:

command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
    \ | diffthis | wincmd p | diffthis

I'm wondered how to do the same, but show a patch instead (like running diff -u) in a new window.

  • Please don’t put answers in the question. Post your own answer instead.
    – D. Ben Knoble
    Apr 23, 2023 at 17:38

1 Answer 1


I would do:

command! PatchOrig silent %y | vert new | set bt=nofile | put | 0d_ | set ft=diff | silent %!diff -u # -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.