I use Text Editor to draft emails and other messages.
Not files that I want to save, just drafts.

Problem: When my computer crashes (happens often recently), I loose the drafts.

Is there a text editor that backs up unsaved files somewhere? (preferably in a single place)

I tried Text Editor (Gedit), and Leafpad.

Note: I don't want ~example files to be created everywhere, because they are a mess in the terminal, and can be dangerous when sharing USB sticks. So unfortunately I can't use GEdit's backup feature.

up vote 3 down vote accepted

Scribes is like Text Editor.

But it saves files automatically in your home folder, with a name like:

oqiowdq - (2013-04-05 16:49:15)

Where "oqiowdq" is the first line you typed.
This file is removed when you really save your file.

Unfortunately, it does not have tabs, so feel free to post better answers.
Also, the line number on the left make the text less readable than Gedit.

If you use gedit, you can turn on autosave in preferences -> editor and it saves documents with the period you specified. And about the autosaved documents place, if I'm right it saves any file in the same folder and same name with extra ~ at the beginning (it would be hidden so press ctrl+H to see it.)

  • Sorry, I should have explained why I can't use this feature, see the notes I added in my question. – Nicolas Raoul Apr 8 '13 at 1:23

I assume you have given a name to your file or saved it before your system crashed, if not Gedit will automatically do that for you, provided that you have set up your editor to save you during these times. Do this:

Open edit, select Edit -> Preferences -> Editor -> Create a Backup of file and Save file every 3 min. 

This must solve any future problems like this.

  • Sorry, I should have explained why I can't use this feature, see the notes I added in my question. – Nicolas Raoul Apr 8 '13 at 1:27

You can also use Notepadqq. It is like Notepad++ in MS Windows. http://notepadqq.altervista.org/wp/download/

  • +1 for Notepadqq. PS: do you know where notepadqq puts the autosaving files? – Lee Oct 31 '17 at 16:23

Besides Notepadqq, another alternative is Geany with Save Actions plugin.

Both of them support autosaving as well as backup.

And both of them can restore the last session on startup.

Vim (and by extension, GVim) has swapfiles, which are usually created in the same directory as the file, but can also be placed in a single common directory. Swapfiles are enabled by default, and for configuring the location, see :h 'directory:

                                                'directory' 'dir'
'directory' 'dir'       string  (default for Amiga: ".,t:",
                                 for MS-DOS and Win32: ".,$TEMP,c:\tmp,c:\temp"
                                 for Unix: ".,~/tmp,/var/tmp,/tmp")
                        global
        List of directory names for the swap file, separated with commas.
        - The swap file will be created in the first directory where this is
          possible.
        - Empty means that no swap file will be used (recovery is
          impossible!).
        - A directory "." means to put the swap file in the same directory as
          the edited file.  On Unix, a dot is prepended to the file name, so
          it doesn't show in a directory listing.  On MS-Windows the "hidden"
          attribute is set and a dot prepended if possible.
        - A directory starting with "./" (or ".\" for MS-DOS et al.) means to
          put the swap file relative to where the edited file is.  The leading
          "." is replaced with the path name of the edited file.
        - For Unix and Win32, if a directory ends in two path separators "//"
          or "\\", the swap file name will be built from the complete path to
          the file with all path separators substituted to percent '%' signs.
          This will ensure file name uniqueness in the preserve directory.

So, in your ~/.vimrc, add:

set directory^=/path/to/swapfiles

And make sure that /path/to/swapfiles exists.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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