18

Possible Duplicate:
Can I see changes before I save my file in Vim?

Duplicate: Can I see changes before save my file in Vim?

Is there a way to see the diff of the saved version and the edited version of the same file in VIM?

This is the scenario: I've opened a file, editing something and I went away from the computer due to some work. After sometime I returned back and I forgot what I was editing and I would like to see the difference between the last saved and the current unsaved version of the same file. Is there a way to do it?

Of course, I can keep undoing till the last change and start redoing to go back to my unsaved version. But what I would like to see is a diff.

Community
  • 1
  • 1
Srikanth
  • 11,780
  • 23
  • 72
  • 92

2 Answers2

40
:w !diff % -
chaos
  • 122,029
  • 33
  • 303
  • 309
  • 3
    Could we get an explanation for this to make it easier to understand? – Marlun Jan 30 '14 at 09:41
  • 3
    @Marlun I have written an explanation in the [question](http://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim/22360650) referenced inside the duplicate notification. – Tobias Heinicke Mar 12 '14 at 18:37
0

Apparently :DiffOrig does the same thing as the custom function did a couple links deep into Mr. Golubyev's post. It may only be in newer versions of Vim by default, though.

danielpcox
  • 466
  • 4
  • 11