Desktop Tools and Development Environment Previous page   Next Page

Incremental Search

With the incremental search feature, the cursor moves to the next or previous occurrence of the specified text in the current file. It is similar to the Emacs search feature. Incremental search is also available in the Command Window--see Incremental Search.

To use the incremental search feature in the Editor/Debugger, follow these steps:

  1. Position the cursor where you want the search to begin.
  2. How you begin the incremental search depends on your setting for the Editor/Debugger key bindings preference and in which direction you want to search:
  1. An incremental search field appears in the left side of the status bar of the current file window. F Inc Search means search Forward from the cursor. The field label is instead R Inc Search when you search backwards.

    Image of Editor with file in it, showing the incremental search field in the lower left corner. The F Inc Search means the increment search will search forward from the cursor.

  1. In the incremental search field, type the text you want to find. For example, type plot.
  1. As you type the first letter, p, the first occurrence of that letter after the cursor is highlighted. In the example shown, the cursor is in the middle of line 2, so the first occurrence of p, the p in problem on line 2, is highlighted.

    Image of first three lines in a file in the Editor showing results of incremental search. Line 2 is %Plot length of sequence for Collatz problem. The cursor is positioned before the word

    Incremental search is case sensitive for uppercase letters. In the above example, searching for uppercase P, would instead find the P in Prepare on line 3.

    When you type the next letter in the term you are searching for, the first occurrence of the term becomes highlighted. In the example, when you add the letter l to the p so that the incremental search field now has pl, the pl in plot on line 8 is highlighted. When you add ot to the term in the incremental search field, the whole word plot in line 8 is highlighted.

  1. To find the next occurrence of plot in the file, press Ctrl+S. To find the previous occurrence of the text, press Ctrl+R.
  2. If MATLAB beeps, it either means the search is at the end or beginning of the file, or it means that the text was not found.
  3. To end the incremental search, press Esc or Enter, or any other noncharacter or number key except Tab or backspace.
  1. The incremental search field no longer appears in the status bar. The cursor is now located at the position where the string was last found.

If you press Ctrl+S or Ctrl+R after displaying the blank incremental search field, the search term from your previous incremental search appears in the field. Then the Back Space key deletes the entire previous search term, rather than just the last letter.


Previous page  Finding Text in Files Opening a Selection in an M-File Next page

© 1994-2005 The MathWorks, Inc.