Find Text in Command Window or History

Find Text in the Command Window

You can search text currently in the Command Window. This includes text that is currently visible on the screen, as well as text that is in the scroll buffer.

Search Using Find Dialog

To search for specified text in the Command Window, on the Command Window title bar, click , and then select Find. The Find dialog box opens. The search begins at the current cursor position. MATLAB® finds the text you specified and highlights it.

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, MATLAB continues searching after beeping.

To search for the specified text in other MATLAB desktop tools, change the selection in the Look in field.

You can increase the amount of information available in the Command Window so that more text is available for searching. Be aware that doing so requires more memory. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Command Window, and then increase the setting for Number of lines in the command window scroll buffer.

Clearing the command window (for example, with the clc function), empties the scroll buffer. The cleared text is no longer available for searching. To clear your display in the Command Window without clearing the buffer, use the home function.

Incremental Search Using Keyboard Shortcuts

This topic shows how to perform an incremental search in the Command Window.

With the incremental search feature, you do not have to leave the Command Window while you perform your search.

  1. Begin an incremental search using one of the following keyboard shortcuts, depending on your operating system's active settings file.

    ActionWindows® Default Active SettingsMacintosh or Emacs Default Active Settings

    Initiate a forward incremental search.

    Ctrl+Shift+SCtrl+S

    Initiate a backward incremental search.

    Ctrl+Shift+RCtrl+R

    An incremental search field appears at the bottom of the Command Window. For a forward search, the text F incSearch appears. The F indicates a forward search.

  2. Begin typing your search term.

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

  3. Perform incremental search actions using the following keyboard shortcuts.

    ActionKeyboard Shortcut

    Complete a partially highlighted string of characters.

    Ctrl+W

    Find the next occurrence of a string of characters.

    Ctrl+S

    Remove characters from the Inc Search field, back to the last successful search

    Ctrl+G

    If you search for a string that does not appear in the Command Window text, Failing appears in the incremental search field.

  4. End incremental searching by pressing Esc (escape), Enter, or any other key that is not a character or number.

    The Inc Search field disappears. The cursor remains at the position where the text was last found, with the search text highlighted.

Find Text in the Command History Window

You can find text in the Command History Window that matches the case. You also can search for text at the beginning of or anywhere within a command.

  1. In the Command History window, type in the Search field. To display the Search field if is not visible, click , and then select Find.

    The Command History window searches backwards and selects the previous entry that contains the sequence of letters you typed.

  2. Find the previous or next occurrence of the entry with the up and down arrow keys, respectively.

  3. Press Esc to clear the search.

Was this topic helpful?