Skip to Main Content Skip to Search
Product Documentation

Find Text in the Command Window

Find Text Currently Displayed in the Command Window

To search for specified text currently displayed in the Command Window:

  1. Select Edit > Find when the Command Window is active.

    The Find dialog box opens.

  2. Complete the dialog box, and then click Find Next or Find Previous.

    The search begins at the current cursor position. MATLAB finds the text you specified and highlights it.

  3. Repeat step 2 to find another occurrence.

    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.

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

Increase the Amount of Information Available for Searching in the Command Window

You can increase the amount of information displayed in the Command Window so that more text is available for searching. Be aware that doing so requires more memory.

  1. Select File > Preferences > Command Window, and then increase the setting for Number of lines in the command window scroll buffer.

  2. Click OK.

Do not clear the Command Window.

In other words, do not enter clc or select Edit > Clear Command Window.

Use Incremental Search in the Command Window

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. The following sections provide details:

Example of Using Incremental Search

You control incremental search using keyboard shortcuts. The following example demonstrates how to use the incremental search feature in the Command Window when:

For details, see Choose a Set of Keyboard Shortcuts.

  1. Clear the Command Window to clear it of existing text and add this text:

    qty = {15, 'Berlin'; 15, 'Boston';  15, 'London'; ...
    15, 'Melbourne'; 21, 'Berlin'; 21, 'Boston'; 21, 'London'; ...
    21, 'Melbourne'; 22, 'Berlin'; 22, 'Berlin'; 22, 'Boston'; ...
    22, 'Boston'; 22, 'London'; 22, 'London'; 22, 'Melbourne'; ...
    22,'Melbourne';};
    
    clc
    
    qty
  2. In the Command Window, position the cursor after the equal sign (=).

  3. Begin an incremental search by pressing Ctrl+Shift+S.

    An incremental search field appears at the bottom of the Command Window with the text F incSearch. The F indicates a forward 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.

  4. Begin a search for Boston by typing b.

    The first occurrence of b highlights.

    If you mistype in the Inc Search field, use the Backspace key to remove the previous letter or letters and make corrections.

  5. Type the next letter of the text you want to find. Type o to specify the next letter in Boston.

    The Inc Search field contains bo, and the bo in Boston highlights.

  6. To complete the highlighted word, press Ctrl+W.

    Boston highlights and appears in the Inc Search field.

  7. Find subsequent occurrences of the word by pressing Ctrl+S one or more times.

    If MATLAB beeps, it means either that the text was not found, or the search wrapped past the bottom (or top) of the Command Window and is continuing at the top (or bottom).

  8. Find previous occurrences of the word by pressing Ctrl+R.

    The incremental search field begins with R to indicate a backward (reverse) search.

  9. Search for a string that does not appear in the Command Window text by typing x.

    MATLAB beeps and Failing appears in the incremental search field.

  10. Automatically remove characters back to the last successful search by pressing Ctrl+G.

  11. End incremental searching by pressing Esc (escape) or Enter.

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

Summary of Keyboard Shortcuts for Incremental Searches

The following table summarizes the keyboard shortcuts you can use for performing incremental search actions. Except for the keyboard shortcuts that initiate an incremental search, you cannot customize these shortcuts. For information on choosing a keyboard shortcuts Active settings file, see Choose a Set of Keyboard Shortcuts.

ActionActive Settings FileKeyboard Shortcut

Initiate a forward incremental search.

Windows Default SetCtrl+Shift+S

Initiate a forward incremental search.

Emacs Default Set or Macintosh Default SetCtrl+S

Initiate a backward incremental search.

Windows Default SetCtrl+Shift+R

Initiate a backward incremental search.

Emacs Default Set or Macintosh Default SetCtrl+R

Complete a partially highlighted string of characters.

Any

Ctrl+W

Find the next occurrence of a string of characters.

Any

Ctrl+S

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

Any

Ctrl+G

End an incremental search.

Any

Esc (escape), or Enter, or any other key that is not a character or number

Case Sensitivity in Incremental Searches

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.

For example, suppose you enter bO in the Inc Search field when the Command Window contains the text shown in the image that follows. Incremental search finds the b in Berlin, but does not find any additional 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.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS