[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8. Searching and Replacing

GPS provides extensive search capabilities among its different elements. For instance, it is possible to search in the currently edited source file, or in all the source files belonging to the project, even those that are not currently open. It is also possible to search in the project explorer (on the left side of the main GPS window), or the help modules,...

All these search contexts are grouped into a single graphical window, that you can open either through the menu Navigate->Find/Replace..., or the shortcut Ctrl-F.

Selecting either of these two options will pop up a dialog on the screen, similar to the following:

search-hide

On this screen shot, you can see three entry fields:

Search for
This is the location where you type the string or pattern you are looking for. The search widget supports two modes, either fixed strings or regular expressions. You can commute between the two modes by either clicking on the Options button and selecting the appropriate check box, or by opening the combo box (click on the arrow on the right of the entry field).

In this combo box, a number of predefined patterns are provided. The top two ones are empty patterns, that automatically set up the appropriate fixed strings/regular expression mode. The other regular expressions are language-specific, and will match patterns like Ada type definition, C++ method declaration,...

Replace with
This field should contain the string that will replace the occurrences of the pattern defined above. The combo box provides a history of previously used replacement strings.

Look in
This field defines the context in which the search should occur. Clicking on the arrow on the right will display the list of all possible contexts. The exact list will depend on what modules were loaded by GPS, since each module can add its own contexts.

Depending on the selected context, extra fields might be displayed on the screen. For instance, if you select the context Files... you will be asked what files or directories should be searched. These are regular expressions.

When searching one or more source files, an extra field to select the scope is provided. This is used to avoid matching on comments when you are only interested in actual code, or to only search strings and comments, and ignore the code.

GPS will automatically select the most appropriate context when you open the search dialog, depending on which component currently has the focus. You can of course change the context to another one if needed.

The second part of the window is a row of buttons, to start the search (or continue to the next occurrence), to stop the current search when it is taking too long, or to display the options.

search-options

There are four check boxes in this options box.

"Search All Occurrences"
The default mode for the search widget is interactive searching: its stops as soon as one occurrence of the pattern is found. You then have to press the Next button (or the equivalent shortcut Ctrl-N) to go to the next occurrence.

However, if you enable this check box, the search widget will start searching for all occurrences right away, and put the results in a new window called Locations (initially found in the bottom dock of the GPS window). You can interrupt the search at any time by pressing the Stop button: this will stop when the next occurrence is found.

"Case Sensitive"
By default, patterns are case insensitive (upper-case letters and lower-case letters are considered as equivalent). You can change this behavior by clicking on this check box.

"Whole Word Only"
If activated, this check box will force the search engine to ignore substrings. "sensitive" will no longer match "insensitive".

"Regular Expression"
This button commutes between fixed string patterns and regular expressions. As mentioned above, you can also commute between these two modes by selecting the arrow on the right of the Search for: field.

As most GPS components, the search window is under control of the multiple document interface, and can thus be integrated into the main GPS window instead of being an external window.

To force this behavior, open the menu Window, select Search in the list at the bottom of the menu, and then select either Floating or Docked.

If you save the desktop (File->Save...->Desktop, GPS will automatically reopen the search dialog in its new place when it is started next time.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Mail Server on June, 15 2003 using texi2html