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:

  1. 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.

  1. Complete the Find & Replace dialog box to find all occurrences of the string you specify.
    1. Type the string in the Find what field.
    2. Select the files to search through from the Look in listbox.
    3. Constrain the search by checking Match case, Whole word, or Wrap around.
  2. Click Find.
  3. Open any M-file(s) in the results list by doing one of the following:

    The M-file opens, scrolled to the line number shown in the results section of the Find & Replace dialog box.

  1. 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.

  1. 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.
  2. 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.
  3. In the Replace with field, type the text that is to replace the specified string.
  4. 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.

  1. 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