1

is there any way I can know all changes I made to a (existing) file before saving it in vi ? In other words any way to do "diff" between saved and edited version of a file in vi. Thanks

2
  • I use vi and vim both.Added vim tag
    – Zxcv Mnb
    Commented Sep 21, 2012 at 6:05
  • If you're stuck wondering why a buffer is marked as edited and don't want to lose the changes, you can always use :w new_file_name and then use plain old diff.
    – noodl
    Commented Sep 21, 2012 at 8:09

1 Answer 1

3

The $VIMRUNTIME/vimrc_example.vim defines a :DiffOrig command that does exactly that. See also :help :DiffOrig for the description. Just copy the command definition to your ~/.vimrc, and you're done!

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