Searching for and Replacing text in files

3.5.1. Searching

To search for a string or regular expression in the current file, choose Edit ▸ Search ▸ Find or press Ctrl+Alt+F. This will open the Find dialog.

Use the text box to specify the string to search for, and select whether it is a normal string or a regular expression. You can also specify the direction of search, whether the search is case-sensitive or not, and the scope of the search. Click Search to start searching.

If the search is successful, Anjuta will jump to the matched text or perform another action (according to the Search Action you choose in the Search Target tab). If the search is not successful, Anjuta will display a message indicating that the search text was not found.

If you want to search again, click the Search button again or press Ctrl+G. This will find the next match (use Shift+Ctrl+G for the previous match). You can even change the search text when you do this; enter the new string in the Search Expression text box in the search dialog.

Figure 3-11Search Text dialog

To stop a long search, press the Stop button.

3.5.2. Specifying Search Range

In the Search Target tab, define the search location and the action to be performed if the search succeeds.

You can define the maximum number of actions to be performed.

Figure 3-12Search Target dialog

You can select which text will be searched.

Figure 3-13Search Target In choice

3.5.2.1. Searching in Files

To find text in your project, set Search In to All Project Files.

In the Search Expression tab, enter the text you want to search for and specify search options, such as the Match case or Match complete words options. Click Search to start searching.

To find text in a set of files, set Search In to Specify File Patterns. Define the search variables. Click Search to start searching.

Figure 3-14Search File Pattern

3.5.3. Specifying a Search Action

You can select which action will be performed when a search succeeds.

Depending on the previous selections (Search In, Search Direction , and so on), some actions may be unavailable.

Figure 3-15Search Target Action choice

3.5.4. Replacing

Searching and replacing is similar to just finding text, except that you also specify the replacement text in the Replace With text box, and also specify whether or not you want to be prompted before each replacement takes place (Replace First Match or Replace All Matches).

Figure 3-16Replacing

Choose Replace to replace the matched text or Forward to jump to the next matched text.

3.5.5. Search Setting

You may also save search options.

The item highlighted in red is the active item. The default item specifies search settings which are loaded when Anjuta launches.

Figure 3-17Search Setting dialog