# 7.5. Searching and Replacing

## 7.5.1. Single File Search

How to find one or more characters in the actual editing window

1. Select "Search" from the "Edit"-menu. This opens the search dialog.

2. Specify the expression to search for in the edit field. The drop-down menu offers selecting a previous search expression.

3. Select additional options like "Whole Words only"

4. Press OK.

To repeat searching for an expression entered in the search dialog, press F3.

## 7.5.2. Searching over Several Files

As the search function only is referencing searches over a single file that is currently visible, you're limited to this. But often you want to search for the same expression overall your project. Therefore, KDevelop contains a `grep` -dialog, which lets you search over all files that you specify either by setting the directory to start the search from and/or by mime-type. Specifying the exact directory and the mime-type will therefore reduce the time that KDevelop needs to read your files and display the results. To start a search over several files, select "Search in files..." from the "Edit"-menu. The search dialog opens and lets you enter:

- The expression to search for (the pattern)

- The template used for the search

- The mime-type of files to search in

- The directory to start form

- If the search is recursive over all included subdirectories

By default, the grep -dialog is set to start at your project directory and works recursively over implementation and header files.

You can even extend your search pattern by using the following options:

1. . Match any character

2. &ˆ; Match the beginning of a line

3. $ Match the end of a line

4. \< Match the beginning of a word

5. \> Match the end of a word

For a repeating search, you can also use the available operators:

1. ? The preceding item matches less than once

2. * The preceding item is matched zero or more times

3. + The preceding item is matched once or more times

4. &{; n &}; The preceding item is matched exactly n times

5. &{; n,&}; The preceding item is matched n or more times

6. &{;,n &}; The preceding item matches less than n times

7. &{;n,m&}; The preceding item matches at least n times but less than m times

Backreferences to bracketed subexpressions are also available by the notation \n.

After specifying your search, press "Search". The results are then displayed in the result-window. To jump to a file and line number, select the resultline and press Intro or double click the result. The editor will automatically open the according file and place the cursor to the line of the result. This allows a complete specification for any search action and give out exact results.

KDevelop offers also some more specialized functionality to use grep within the editor s and the browser. Select the expression you want to search for in either of the windows and press Mayús+F2 or select "grep :&<;your&_;expression&>;" from the right button popup menu. This will ask grep to search for the selection in your project directory's files and will show the results immediately. Switching to the result works as described above. From within the editor window, it lasts to place the cursor over a word and start searching; the word under the cursor will be the search pattern.

## 7.5.3. Searching within Documentation

While working on a project, you often need to have information about the parameters of member functions you want to use- most often you remember the function's name that matches your needs, but the parameters are a very hard thing to keep in mind. Therefore, and for other purposes that may occur, KDevelop contains a search functionality that combines searching expressions that appear in your files with the documentation browser . To make use of this search functionality, you should have set up the documentation browser correctly and created the search database. For invoking a search through the documentation, do the following:

1. place your cursor at the word you want to search or mark an expression

2. select "Search Marked Text" from the Help-menu or press the right mouse button to open the context menu; then select "Look Up: "expression".

3. after the search result page is displayed in the documentation browser , select the page that you think could contain the information you need.

4. the selected documentation page is displayed and your search result is marked. To display the next result within the same documentation page, press F3.

This allows you to easily find the information you need. For using the results, the documentation browser allows marking a selection and copying it to the clipboard. Then return to the file you're editing and select "Paste" from the "Edit"-menu.

For a full description on how to use the Documentation, see Using the Searchindex.

## 7.5.4. Replacing Text

For replacing an expression, select "Search and Replace" from the "Edit"-menu. The "Search and Replace"-dialog lets you specify the expression to be replaced as well as the replacement expression. Then press OK. The first expression which is found will be marked, so you can see where the expression is and in which context. Then you can specify by a dialog if the expression shall be replaced or not. When the search is finished by reaching the end of the current file, you will be asked if you want to start the search again from the beginning. If you're finished, select "Cancel".