Question

I often get a notification to my Vim that my file has been changed elsewhere, since I use Dropbox.

I then need to press

L 

because it is my only way to get to see the file changed by my friend. This forces me to use his version and then just try to remember the changes which I did.

This procedure however is becoming difficult for me, since the rate of edits has grown. I would like to

 vimdiff [file_with_my_edits] [file_with_my_friend's_edits] 

somehow the version of my friend with my current file which has some new edits.

How can you vimdiff your current file with your friend's file when the version base is the same but the current files are different, without losing any edits?

Was it helpful?

Solution

If two (or more) people are working on a file simultaneously, you should use a version management system like subversion or git. As you've already seen, dropbox isn't the solution in this case.

OTHER TIPS

This vim tip gives a function to diff the current buffer with the file on disk. It's intended to show you the edits you have made since last saving, but it will also show you the edits made by your friend.

While I agree that you should be using source control, what you want can be accomplished in vim. You can choose not to load your friend's edits, save yours to a new file, then use vimdiff. You can even do all that without leaving vim:

  1. :w file_with_edits.new (saves your changes to a new file)
  2. :e file_with_edits (discards your changes)
  3. :diffthis (turns on diff for the current buffer)
  4. :vsplit (opens a vertical split, showing the current file in both windows)
  5. ^w, right (switches to the right split)
  6. :e file_with_edits.new (opens your changes)
  7. :diffthis (turns on diff for the right side)

All that said, source control makes this kind of thing trivial (it's one of its primary goals).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top