Saving Files

Changed made in a buffer do not affect the file on disk until the buffer is saved.

File>Save (shortcut: C+s) saves the current buffer to disk.

File>Save As renames the buffer and saves it in a new location. Note that using this command to save over another open buffer will close the other buffer, to stop two buffers from being able to share the same path name.

File>Save a Copy As saves the buffer to a different location but does not rename the buffer, and does not clear the “modified” flag. Note that using this command to save over another open buffer will automatically reload the other buffer.

File>Save All (shortcut: C+e C+s) saves all open buffers to disk, asking for confirmation first. The confirmation dialog can be disabled in the General pane of the Utilities>Global Options dialog box.

Two-Stage Save

To prevent data loss in the unlikely case that jEdit should crash in the middle of saving a file, files are first saved to a temporary file named #filename#save#. If this operation is successful, the original file is replaced with the temporary file.

However, in some situations, this behavior is undesirable. For example, on Unix this creates a new i-node so while jEdit retains file permissions, the owner and group of the file are reset, and if it is a hard link the link is broken. The “two-stage save” feature can be disabled in the General pane of the Utilities>Global Options dialog box; see the section called “The General Pane”.

Autosave and Crash Recovery

The autosave feature protects your work from computer crashes and such. Every 30 seconds, all buffers with unsaved changes are written out to their respective file names, enclosed in hash (“#”) characters. For example, program.c will be autosaved to #program.c#.

Saving a buffer using one of the commands in the previous section automatically deletes the autosave file, so they will only ever be visible in the unlikely event of a jEdit (or operating system) crash.

If an autosave file is found while a buffer is being loaded, jEdit will offer to recover the autosaved data.

The autosave interval can be changed in the Autosave and Backup pane of the Utilities>Global Options dialog box; see the section called “The Autosave and Backup Pane”.

Backups

The backup feature can be used to roll back to the previous version of a file after changes were made. When a buffer is saved for the first time after being opened, its original contents are “backed up” under a different file name.

The behavior of the backup feature is specified in the Autosave and Backup pane of the Utilities>Global Options dialog box; see the section called “The Autosave and Backup Pane”.`

The default behavior is to back up the original contents to the buffer's file name suffixed with a tilde (“~”). For example, a file named paper.tex is backed up to paper.tex~.

  • The Max number of backups setting determines the number of backups to save. Setting this to zero disables the backup feature. Settings this to more than one adds numbered suffixes to file names. By default only one backup is saved.

  • If the Backup directory setting is non-empty, backups are saved in that location. Otherwise, they are saved in the same directory as the original file. The latter is the default behavior.

  • The Backup filename prefix setting is the prefix that is added to the backed-up file name. This is empty by default.

  • The Backup filename suffix setting is the suffix that is added to the backed-up file name. This is “~” by default.

  • Backups can optionally be saved in a specified backup directory, instead of the directory of the original file. This can reduce clutter.

  • The Backup on every save option is off by default, which results in a backup only being created the first time a buffer is saved in an editing session. If switched on, backups are created every time a buffer is saved.