Saving Files

Any changes made to a buffer aren't actually stored to disk immediately; instead, they are stored in the computer's high speed memory (RAM) until they are saved. File>Save (keyboard equivalent: Control-S) will immediately save the current buffer to disk, unless the buffer is untitled, in which case it will prompt for a file name first. File>Save As also saves the buffer to disk, but prompts for a file name every time. File>Save All Buffers (keyboard equivalent: F4) will save all open buffers immediately; a confirmation dialog box will be issued first.

Autosave and Backups

jEdit's autosave feature protects against computer crashes and such. Every 15 seconds, all buffers with changes are written out to their respective file names, enclosed in hash ("#") characters. (For example, program.c will be autosaved to #program.c#). When you save a buffer, its autosave file is deleted. But if jEdit crashes before you can save a file, the autosave will remain, with your unsaved changes in it. Next time that file is opened, jEdit will ask if you want to recover the autosaved data.

Figure 3-6. Dialog box shown if a file has autosaved changes

Another useful safety feature is file backups. When you save a buffer for the first time after opening it, its original contents are saved to the buffer's file name suffixed with a tilde ("~"). For example, paper.tex is backed up to paper.tex~. The point of backups so that if you make extensive changes to a file, and then change your mind, you can go back to the previous version.

Tip: The autosave frequency and various backup-related settings can be changed in the Utilities>Global Options dialog box; see the section called The Global Options Dialog Box in Chapter 8.

Line Separator Characters

The three major operating systems use different conventions to mark line endings in text files. The MacOS uses Carriage-Return (\r, ^M) for that purpose. Unix uses Newline (\n, ^J). DOS and Windows use Carriage-Return-Newline (\r\n, ^M^J). jEdit can read and write all three formats. The line separator used in a buffer can be changed in the Utilities>Buffer Options dialog box; see the section called The Buffer Options Dialog Box in Chapter 8. The default for new files can be changed in the Utilities>Global Options dialog box; see the section called The Global Options Dialog Box in Chapter 8.

When Another Application Modifies the File

jEdit will issue a warning message if it notices that another application has changed an open buffer on disk. You will be given the choice to continue editing (and lose changes made by the other application) or to reload the buffer.

File>Reload (keyboard equivalent: F2) can be used to reload a buffer from disk at any other time. If the buffer has unsaved changes, you will be asked for confirmation first. File>Reload All Buffers (keyboard equivalent: Shift-F2) will discard changes in all open buffers and reload them from disk. This command will also ask for confirmation. It is useful after performing a CVS checkin or similar; CVS inserts version info in all files it commits, hence they must be re-read from disk.

Figure 3-7. Warning message displayed when another application changed the file on disk