Desktop Tools and Development Environment Previous page   Next Page

Searching in the Command Window

You can search for specified text that appears in the Command Window, where the text was either part of input you supplied, or output displayed by MATLAB. There are two search features for the Command Window:

After finding the text, you can copy and paste it to the prompt in the Command Window to run it, or into an M-file or other file.

See also Recalling Previous Lines, Tab Completion, and Keyboard Shortcuts in the Command Window for techniques to reuse previous statements and navigate in the Command Window.

Find Dialog Box

Select Find from the Edit menu to search for specified text using the Find dialog box. Complete the dialog box. The search begins at the current cursor position. MATLAB finds the text you specified and highlights it. Click Find Next or Find Previous to find another occurrence, or use the keyboard shortcuts F3 and Shift+F3.

Image of Find dialog box. The Look in field shows Command Window, indicating the find operation will look through the text in the Command Window.

MATLAB beeps when a search for Find Next reaches the end of the Command Window, or when a search for Find Previous reaches the top of the Command Window. If you have Wrap around selected, it continues searching after beeping.

Note that you can only search for text currently displayed in the Command Window. To increase the amount of information maintained in the Command Window, increase the setting for the command session scroll buffer size in Command Window preferences, and do not clear the Command Window.

Change the selection in the Look in field to search for the specified text in other MATLAB desktop tools.

Incremental Search

With the incremental search feature, the cursor moves to the next or previous occurrence of the specified text in the Command Window. It is similar to the Emacs search feature. To use the incremental search feature in the Command Window,

  1. Position the cursor where you want the search to begin.
  2. How you begin the incremental search depends on your setting for the Command Window key bindings preference:
  1. To look for the previous occurrence, press Ctrl+R or Ctrl+Shift+R instead.

    An incremental search field, Inc Search, appears at the bottom of the Command Window and is preceded by F for a forward search, or R when you are looking for the previous occurrence (reverse search).

    Image of Command Window showing the incremental search field. Text in the Command Window consists of a 16x2 cell array, with  numeric data in column 1 and strings in column 2. The strings are names of cities: Berlin, Boston, London and so on.

  1. In the Inc Search field, type the text you want to find. For example, look for Boston.
  1. As you type the first letter, b, the first occurrence of that letter in the Command Window after the current cursor position is highlighted. For the example shown, the first occurrence of b is highlighted, the b in Berlin. Note that incremental search allows for case sensitivity--see Case Sensitivity in Incremental Search.

    When you type the next letter, the first occurrence of the text becomes highlighted. In the example, when you add the letter o to the b so that the Inc Search field now has bo, the bo in Boston becomes highlighted.

  1. To find the next occurrence of Boston in the Command Window, press Ctrl+S. To find the previous occurrence of the text, press Ctrl+R.
  1. If MATLAB beeps, the display shows Failing F Inc Search, followed by the text you entered. This means either that the text was not found, or the search wrapped past the end or beginning of the Command Window.

  1. To end the incremental search, press Esc or Enter, or any other key that is not a character or number.
  1. The Inc Search field no longer appears. The cursor is at the position where the text was last found, with the search text highlighted.

Incremental search is also available in the Editor/Debugger--see Incremental Search.

Case Sensitivity in Incremental Search

When you enter lowercase letters in the Inc Search field, for example, b, incremental search looks for both lowercase and uppercase instances of the letters, for example b and B. However, if you enter uppercase letters, for example, B, incremental search only looks for instances that match the case you entered.

In the example, enter bO in the Inc Search field and incremental search does not find any matching text.

Image of Command Window and incremental search field. The field shows Failing F Inc Search: followed by a lowercase b and an uppercase O. There is no text in the Command Window that contains a b followed by an uppercase O.


Previous page  Keeping a Session Log Preferences for the Command Window Next page

© 1994-2005 The MathWorks, Inc.