2

Currently, a colleague and I are working on a joint project written in LaTeX. I am using a plugin (VimTeX) which, in addition to calling a compiler tool (upon saving the file) offers some bindings for ease of use. Given my familiarity with the plugin and vim in general I would prefer not to switch to another option.

Recently, we noticed that his editor (TeXStudio) will catch all the changes I make once I save (we are sharing via Dropbox) while we are simultaneously editing the .tex file. It also appears that after a few second delay (following a save on his end) gvim will let me know that changes have been made to the file and prompt me to either open the edited version or not -- however doing this I seem to lose my work as I can't save the file without overwriting the work he just completed. I appreciate that vim lets me know that he has recompiled the file, but could it just make the changes he saved and act as nothing I've done has changed?

For clarity I am providing an example:

  • Friend and I both have editor open to shared .tex file.
  • Friend adds text to section 2.
  • I add text to section 3.
  • If my friend saves the file first I eventually get a message from vim as I described above.
  • If I use his saved version then I lose the changes I made to section 3. If instead I keep going with my version and save, his changes are never seen by my editor, and so once I save it will overwrite the changes he just made.
  • If I save the file first, he will see the changes I made to section 3 pop up in his editor and he gets to keep his work (in section 2). Then, he can save the file with both of our changes in place.

My preference would be for the work I'm doing and the work my friend has done to merge nicely similar to the way things work on his end. We don't work on the same sections of the document at the same time so there is no harm in this type of result being achieved. If this cannot be done, I am open to other suggestions.

  • It's a bit hacky, but I use the function described in this answer for a similar scenario. When notified of the changes, I say that I want to keep my version, and then use the function to diff against the saved version (which is his version), and I can then manually copy across the changes. – Rich Feb 11 '17 at 15:58
1

I don't really know a good solution that does things the way you want it to work. As far as I know, Vim is not really designed for this scenario, and as such, I would expect any solution to be rather hackish.

However, I will dare to suggest that "you are doing it wrong". That is, if you are collaborating with a LaTeX document, then you really should be using a version control system (VCS) such as Git or Mercurial. Heck, you should use VCS's even if you are working on personal documents.

The workflow would be slightly more "complicated" than the one you are using now. First, both you and your friend would need to know/learn a VCS. In a typical VCS workflow, you would communicate with each other through a central repository where you both committed or pushed changes. Even though this would be more complicated, it would also provide a lot of benefits, such as a good version history, better handling of conflicting edits, and it would be "trivial" to work together on the same document, at the same time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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