tags:

views:

214

answers:

3

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?

+6  A: 

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.

Paul Tomblin
+1. I can't imagine trying to simultaneously edit a shared file on what is essentially a network drive.
Greg Hewgill
I use Git, but I have not managed to allow my team mate push to my git-repo such that I cat identify each edit. This suggests me that we should apparently have two repos with the same base. However, I am not sure how to compare his changes to my base. I know `opendiff` file1 file2. I should apparently `opendiff my_branch his_branch`. However, I am not sure how to do that.
Masi
Maybe if you put the git repository on the dropbox, and both you have your own checkouts separately that you push to the one on the dropbox?
Paul Tomblin
A: 

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).

Thomas G. Mayfield
This is the procedure which I have been using. I use Git for my personal source control. -- I need to solve how to get my friend's branch to my computer.
Masi
+4  A: 

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.

Rodrigo Queiro