3. Navigation and Managing documents

3.1. Navigating through a document

The editing area is a standard GTK editing area. This means there are many keyboard shortcuts available to navigate through the text.

  • control+right-arrow will jump to the next word boundary

  • control+left-arrow will jump to the previous word boundary

  • end will jump to the end of line

  • home will jump to the beginning of the line

  • page-up will jump one page up

  • page-down will jump one page down

  • control+home will jump to the top of the document

  • control+end will jump to the end of the document

These shortcuts are also available when selecting text. Some examples: To select the current line, press home, hold shift and press end. To select the current word, press control+left-arrow, hold shift and press control+right-arrow.

3.2. Navigating through many documents

Navigating through a large list of documents can be difficult. But if you right-click the document notebook tabs, you get a list of all opened documents.

Navigation between documents can also be done using the Go menu.

Figure 3.18. Bluefish Go Menu

A screen shot of the Bluefish 0.14 go menu

  • control + page-up will change to the previous document

  • control + page-down will change to the next document

3.3. Projects

Figure 3.19. Bluefish Project Menu

A screen shot of the Bluefish 0.14 project menu

The projects are a sort of 'saved state' of Bluefish. All files open when the project is saved, are automatically opened the next time you open the project. Also the recently used files in that project are shown in the recent menu. Furthermore, a basedir can be set, so the file browser in the left panel will only show the files in the basedir and its subdirectories. If Bluefish is installed with gnome-vfs support the basedir might be remote, for example sftp://someserver/somedir or smb://user:password@server/someshare/.

If the webdir is entered in the project settings, Bluefish will launch the browser to the appropriate URL. If your basedir for example is /var/www/ and your webdir http://localhost/ Bluefish will use this information to launch the browser to the correct URL. This can be very convenient for testing server side scripting languages like PHP, JSP or other.

The template field can point to a template file. If the 'new file' button is clicked, the contents of this file will be automatically loaded into the edit window.

The projects will be expanded to have more Bluefish settings, so a project can be a bit of customized Bluefish setup. Currently the state of various tool bars and menu bars is saved in a project file.

The project file itself is simply a text file in the standard Bluefish format (same format as the config file). This format is 'key: value'.

3.4. Bookmarks

In Bluefish you can add bookmarks to a line in the text, and you can later use the bookmark to quickly jump to this location. Bookmarks can be temporary or permanent, the default can be configured in the preferences.

Bookmarks can be added to the current cursor location by using the menu /Edit/Add bookmark, or by using the shortcut key combination control+d. You can also add bookmarks by right-clicking in the text, and selecting add bookmark.

Bookmarks can be temporary or permanent. Permanent bookmarks are stored, and temporary bookmarks are gone after Bluefish is closed. The default is set in the preferences under Editor. If you right click a bookmark and select Edit you can change this setting for a bookmark.

SCREENSHOT BY ????

A way to add many bookmarks at the same time is using the Find dialog. Check the 'Bookmark results' option, and all search results will be added to your bookmarks. For example this manual has sections, and each section is identified by a header like '<sect1 id="bluefish-ch-4-sect-6">'. A way to automatically get a bookmark to every section is to search for the following regular expression pattern: '<sect[0-9]+ id="[^"]+">' and bookmark all results.

Bookmarks can be found in the side panel, sorted by document and line number. If you right click a bookmark, you get a pop up menu with several options. Among the option is edit, which allows you to change a bookmark from temporary to permanent or the other way around, and you can name bookmarks.

3.5. Find and Replace

The edit menu features several options for Find and Replace. The Find... (Ctrl+F) and Replace... (Ctrl+H) menu items will simply start the dialogs described elsewhere in this manual. The Find again (Ctrl+G) item will repeat the last used search. It will continue the search after the position where the previous search was stopped. If the end of file is reached, it will restart at the beginning or continue with the next file, depending on the search options used.

SCREENSHOT BY ????

The Find from selection item will search for the currently selected text. If you select for example the name of a function, in bluefish, or in any other program, and you choose find from selection Bluefish will start a new search for this selected string.

3.5.1. Find or replace with regular expressions

With the find and replace you can do incredible things. We'll start with a simple example. In some HTML table we have several table data tags where we actually want table header tags. Table data is <td></td> and we want <th></th>.

SCREENSHOT BY ????

we can do two normal replaces: one where we replace <td> with <th> and then another where we replace </td> with </th>

we can also do one replace using regular expressions: find (<|</)?td> and replace with \0th> For more information about regular expressions you might want to read man 7 regex, or read any of the great Internet sites about regular expressions. The \0 in the replace string refers to the first subpattern match in the search pattern, the \1 to the second etc.

if you understand the above example, you will realize that you can do much more. Suppose you also want to match a table data tag that does have some attributes like <td class="myclass">, and you want to keep the option while converting to table header. The following pattern will do this: find (<|</)td([^>]*)> and replace with \0th\1>

if you have any search and replace patterns you use often, you can also add them to the Custom Menu. Check the Custom Menu section of this manual for more information.

In the find and the replace dialog it is not possible to insert keys Enter or Tab. You can, however, insert escape characters, if you enable the 'Patterns contain backslash sequences' option. If you use this option, you can add a newline to your pattern as \n, a tab as a \t, and a backslash becomes a \\.

Another useful option in the find dialog is the bookmark results option. For example in a PHP document, you could search for the word 'function', and add a bookmark to every function. This results, however, in a list of bookmarks that are all named 'function'. Not so useful. But also now we can make use of a regular expression. The expression 'function[ \t\n]+[&a-zA-Z0-9_]+' will result in all functions and their name. Much more useful!

SCREENSHOT BY ????