File Buffer Basics

The File > Open command opens a file on disk and loads it into a file buffer. A file buffer is the temporary image of the file that you can edit. You can edit the file buffer without affecting the original file, until you save it using the Save command.

The File > Save command writes the file buffer contents back over the original file. This is the only time the original file is changed.


Figure 4.16 Open and Save operations.

When you close the file, the file buffer contents are simply thrown away. The original file on disk is not changed unless you use the Save command first.

All changes are recorded in the temporary file buffer until the file is saved. When the file is saved, a new file is created and written and the original file is either deleted, or optionally moved to the backup directory. Once the new file is completely and safely written to disk, the file is renamed back to the original file name. By not altering the original file until it is saved, Source Insight provides a safe mechanism for modifying files.

It is helpful to think of using a file buffer when editing a file, however throughout this documentation, when references are made to an “open file”, it actually means a file buffer. Source Insight maintains a close connection between an open file and its original, base file. Therefore, you can think of the Open command as a command that opens the original file so that you can edit it, rather than a command that copies the original file into an abstract buffer that exists independently of any files. You can think of the Save command as synchronizing the original version with the edited version.

Source Insight is used to edit ASCII text files. Source Insight was not designed to edit non-ASCII files. There is nothing to stop Source Insight from opening such a file, however. In the event that a file you open contains non-ASCII characters, Source Insight will not allow you to save the file without first asking if you are sure you want to. You usually do not want to do so, since Source Insight treats CR/LF sequences as end of line markers, and will always make sure a saved file contains a CR/LF sequence at the end.

You can also open virtually any type of file by dragging a file and dropping it onto the Source Insight application window. This includes project files (.PR), configuration files (.CF3), workspace files (.WK3), and clip files (.CLI), in addition to ordinary text files.

In this section: