[Tex/LaTex] Texmaker: automatically save .tex files currently opened every 5 minutes

texmaker

With Texmaker, is it possible to automatically save .tex files currently opened every 5 minutes?

I have found this related post, but the question is about saving automatically whenever compilation occurs. I sometimes write for a long time without compiling, so I don't find that safe enough. I would like the .tex file to save automatically every 5 minutes, regardless of how long ago it was last compiled.


I am using Texmaker 4.1 on Ubuntu 14.04 trusty.

Best Answer

Accessing Texmaker's autosave feature

Texmaker (at least 4.1 and newer) has an autosave feature. How you access it depends on your platform.

  • On Linux (and Windows?), you need to follow Options > Configure Texmaker > Editor.
  • On Mac OS X, you need to follow Texmaker > Preferences > Editor.

You should then see a checkbox that reads "Backup [sic] documents every 10 min". As of Texmaker 4.2, the time interval between two autosaves is 10 minutes and cannot be adjusted by the user.

enter image description here


Compiling often is good

In my opinion, you should compile relatively often. The benefits of compiling often are discussed in the answers to this Programmers.SX question, and apply to TeX & friends as well.

In a nutshell, you can think of compilation as a form of feedback. Compiling often means a short feedback loop: if you make a mistake, you'll find out about it more rapidly and you'll be able to correct it right away. By compiling comparatively less often, you expose yourself to the risk of getting into tricky situtations that you may have trouble extricating yourself from.

Autosave is (mostly) evil

Autosave features such as that offered by Texmaker are dangerous. Imagine the following sequence of events.

  1. Your document is a state that you're not happy with (perhaps you're making wild experiments with it, but you're not yet sure that you're happy with the results).
  2. Texmaker's autosave feature saves your document.
  3. You inadvertently close Texmaker.

The last "good" version of your file is now irremediably gone! You could launch Texmaker again, reopen your file, but you wouldn't be able to undo any of the "bad" changes, because Texmaker's undo list was cleared when the app was closed. This horror story, which isn't that farfetched, is scary enough to keep me away from using any form of autosave.

Use a Version Control System (but not as an autosave!)

You should use some Version Control System instead of using Texmaker autosave feature. A VCS such as Git encourages you to take a snapshot of your project every time you feel that recording the current state might be useful. You can then move back and forth between versions, compare versions to see what changed, etc.

However, emulating some autosave feature with a VCS is wrong, IMO. For instance, using cron to automatically commit every n minutes is completely at odds with Git's philosophy. Each snapshot should instead be taken in a conscious manner and have some meaning attached to it, instead of being created in a rather arbitrary fashion, when n minutes happen to have elapsed since the last one.

Related Question