2. Working with files

Most of the file operations are accessible from the File. Through it, a new file can be created, existing files opened, and opened files saved or renamed.

It is also possible to insert a file into another one, and to revert a modified file to its previously saved state.

Figure 3.11. Bluefish File Menu

A screen shot of the Bluefish File Menu

2.1. Creating files

Apart from using File->New (Ctrl-N) or the New icon to create a new file, you may also use File->New Window (Shift-Ctrl-N).

Both methods create an untitled file of type text with the default character encoding defined in preferences.

2.2. Opening files

Through File->Open... (Ctrl-O) one or more files can be opened. As for creating files, you may want to open the files in a new window. In this case, use File->New Window to first open the new window and then open the desired files as usual.

Figure 3.12. Bluefish Open File Dialog

The Open File Dialog

Note

The latest opened directories appear in the upper part of the left side panel, while you have the possibility to add the most often accessed directories to the lower part. You may also filter the files to be opened with the pop menu located on the right side, whose contents mirror the file types defined in preferences.

Recently opened files can be opened by selecting them from the list within File->Open recent. The number of files in this menu can be set in the preferences under Files.

The file browser in the side panel can also be used to open files. It supports filtering files, by right clicking the contextual menu in the filebrowser. If you right click a directory, you can make this directory the base directory for the filebrowser using the Set as basedir option. Then you can access it directly from the popup menu in the upper part of the file browser.

Figure 3.13. Filtering Files with the Bluefish File Browser

Filtering Files with the Bluefish File Browser

By default the filebrowser follows the document focus. If you change to a different document, the filebrowser will show the contents of the directory where this document is located. This behaviour can be changed on the bottom of the filebrowser.

Information about currently opened files can be seen if you move the mouse over the document tab (by default on the bottom of the screen). A so called tooltip will be shown with information about the full path, size, permissions, filetype and encoding of the file.

Figure 3.14. Info on open file with the Bluefish File Browser

Info on open file with the Bluefish File Browser

An interesting feature of Bluefish is the ability to open files by selecting the text of a currently opened file. For example, if a filename is shown in say a terminal application, you can select the filename, and use File->Open from Selection to open that file. The file, if it exists, will be opened in another tab within Bluefish.

Finally, files can be opened via the command line by feeding filenames to Bluefish as arguments. This can even be done while Bluefish is running and the resulting file will then show up in its own tab.

Files can also be opened by clicking on the Open... icon in the main toolbar.

Note

If you have installed gnome-vfs or gnome-vfs2 before installing Bluefish, you will be able to open files on remote desktop.

2.3. Saving files

If a document is modified, the filename is shown in red in the document tabs, and also if you right click on the tabs, the full path is shown in red in the list that will pop up.

Figure 3.15. Tool Tip for Modified File

Tool Tip for Modified File

To save a document, you can use the File menu, the Save icon in the toolbar, or press the shortcut key combination Ctrl-S. By default a backup is made during save. The original file is copied to the same filename with a tilde ~ appended. This suffix and the backup behaviour can be changed in the preferences under Files.

Before saving the file, Bluefish will check if the original file was changed on disk, using the last modified time and the file size. On some filesystems the last modified time is sometimes not very precise (most notably on samba mounts). This makes Bluefish think the file is modified when it is not. This check can be changed in the preferences under Files.

You can also save a document under a different name, using the Save As... (Shift-Ctrl-S) menu entry, or the Save As... icon in the main toolbar. The original file will still exist.

Figure 3.16. Saving a File under a new Name

Saving a File under a new Name

To save all modified files, you can use the File->Save All menu entry. This will save all documents that have been modified and bring you a save dialog if some files are new files.

2.4. Renaming files

It is also possible to move or rename a document, using the File->Rename... (F2) menu item.

Figure 3.17. Moving a file to another location

Moving a file to another location

2.5. Editing

2.5.1. Undo and Redo

The undo and redo functionalities are available from the Edit menu, the main tool bar, and the keyboard shortcuts.

  • Undo (Ctrl-Z)

  • Redo (Shift-Ctrl-Z)

The functions Undo All and Redo All in the Edit menu will undo or redo all of the stored changes. The maximum number of changes can be configured in the preferences, by default Bluefish will remember the last 100 changes per document. It is possible to clear the changes after the document is saved, an option in the preferences which is disabled by default.

2.5.2. Cut, Copy, and Paste

The functions Cut, Copy, and Paste are available from the Edit menu, the main tool bar, and the keyboard shortcuts.

  • Cut (Ctrl-X)

  • Copy (Ctrl-C)

  • Paste (Ctrl-V)

On X Windows Systems, you can also paste the current selected text using the middle mouse button. First select some text (in Bluefish or in any other X application), then press the middle mouse button where you want to paste the selected text.

Cut or copy and then paste can also be done by selecting some text and dragging it to the destination. If the text is dragged to another document (or another application), it is copied. If the text is dragged within one document it is moved. Dragging to other applications is not possible to every application, but most Gnome and GTK programs are supported.

2.6. File types

The file type of a file changes the behaviour of Bluefish. File types are recognised by their extension, or by the beginning of the content of the file. The current document type is shown in the far right of the status bar. How these extensions and patterns can be changed is described in the "Customising Bluefish" section.

If the type of a file is not properly detected, you can change the type using the Document/Type menu.

2.6.1. Syntax highlighting

Syntax highlighting is the coloring of words that have a special meaning in the language you are writing. Obviously the patterns are different for every language. The "<title>" word for example means "start of title" in HTML, the "function" word means "start of function" in PHP.

During the editing, Bluefish will only update the highlighting patterns in the block of text around the cursor. The number of lines (the size) of this block can be adjusted in the preferences under Editor.

The syntax highlighting for the total document can be refreshed using the Document->Update Highlighting (F5) menu. The syntax highlighting can be disabled in the preferences under Editor.

2.7. More on files

2.7.1. Remote files

Assuming a working Internet connection, files can also be opened from the web using File->File > Open URL (make sure to type the http:// or it doesn't work... bug, maybe???). TO BE WRITTEN BY ???

SCREENSHOT BY ????

2.7.2. Character encoding

There are many different standards for character encoding of text files. Most well known is the ASCII standard, which describes only 127 characters, and is supported by every text editor on the world. The most common standard nowadays is UTF-8, which describes thousands of characters, and is backwards compatible with ASCII. Internally, Bluefish will always work with UTF-8. When opening a file, Bluefish has to detect the correct encoding for the file. For HTML files the encoding should be present in a <meta name="encoding" tag. Bluefish will always use this tag if it is available in the file. If this tag has an encoding that is not present in the Bluefish config file, this encoding is automatically added to the Bluefish config file.

The locale also defines a default encoding. If you are using a locale (a local setting, defining language, time format, currency format, number formatting etc.) Bluefish will try to load the file using the encoding defined in the locale.

Bluefish itself also has a setting for a default encoding. This is the next encoding Bluefish will try. This is also the encoding Bluefish will use for files created by Bluefish (UTF-8 by default).

If these steps fail, Bluefish will simply try every encoding defined in the Bluefish config file.

Filenames on disk can also contain more then ASCII characters. All Gnome and GTK programs (including Bluefish) assume that filenames are in UTF-8 encoding. If you have filenames in the encoding of your locale on your disk, you have to set G_BROKEN_FILENAMES=1 in the environment to make Gnome and GTK programs detect this encoding.

2.7.3. Open advanced

In the File > Open Advanced dialog, accessible from the File->File > Open Advanced... menu item, multiple files can be opened from a directory based on their extension or by their content. The same functionality is available from the filebrowser in the side panel. If you right click a directory, you can also there select Open advanced....

SCREENSHOT BY ????

To open all files by extension, enter the extension in the dialog, and leave the search pattern empty. Check the recursive option if you want to include all subdirectories in the search.

To open files by content, leave the extension at *, and enter a search pattern in the dialog. You can use regular expression patterns if you check the Is regex option.

The open advanced functionality runs the find and grep utilities to get a list of filenames. If these utilities are not available on your system the functionality is not available.