Development Environment |
 |
Finding and Replacing a String
You can search for a specified string within multiple files, and replace the string within a file.
Finding a String. To search for a string in files:
- Click the find button
in the Editor/Debugger toolbar, or select Find and Replace from the Edit menu.
The Find & Replace dialog box appears. This provides the same features as the Find & Replace dialog box accessible from the Current Directory browser.

- Complete the Find & Replace dialog box to find all occurrences of the string you specify.
- Type the string in the Find what field.
- Select the files to search through from the Look in listbox.
- Constrain the search by checking Match case, Whole word, or Wrap
around.
- Click Find.
- If you search is for the current file, the next occurrence of the string is highlighted in the file.
- If the search is through multiple files, results appear in the lower part of the Find & Replace dialog box and include the filename, M-file line number, and content of that line.

- Open any M-file(s) in the results list by doing one of the following:
- Double-clicking it.
- Selecting it and pressing the Enter or Return key.
- Right-clicking it and selecting Open from the context menu.
The M-file opens, scrolled to the line number shown in the results section of the Find & Replace dialog box.
- If you perform another search, the results of each search are accessible via tabs just below the results list. Click a tab to see that results list as well as the search criteria.
Function Equivalent. Use lookfor
to search for the specified string in the first line of help in all M-files on the search path.
Replacing a String. After searching for a string within files, you can replace the specified content in the current file.
- Open the file in the Editor if it's not already open. You can open it from the Find & Replace dialog box - see step 4 in Finding a String. Be sure that the file in which you want to replace the string is the current file in the Editor.
- Be sure the Look in field in the Find & Replace dialog box shows the name of the file in which you want to replace the string. The Replace button in the Find & Replace dialog box becomes selectable.
- In the Replace with field, type the text that is to replace the specified string.
- Click Replace to replace the string in the selected line, or click Replace All to replace all instances in the currently open file.
The text is replaced.
- To save the changes, select Save from the File menu.
You can repeat this for multiple files.
| Navigating in an M-File | | Saving M-Files |  |