| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
Finding Text Currently Displayed in the Command Window Increasing the Amount of Information Available for Searching in the Command Window |
You can search for specified text that appears in the Command Window, where the text is either part of input you supplied, or output displayed by the MATLAB software. 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.
For techniques to reuse previous statements and navigate in the Command Window, see also Recalling Previous Lines in the Command Window, and Completing Statements in the Command Window — Tab Completion. To find files and text in files, see Viewing Files and Folders.
To search for specified text currently displayed in the Command Window, follow these steps:
Select Edit > Find when the Command Window is active.
The Find dialog box opens.

.
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.
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.
To increase the amount of information displayed in the Command Window so that more text is available for searching, follow these steps:
Select File > Preferences > Command Window, and then increase the setting for the Number of lines in command window scroll buffer.
Do not clear the Command Window.
In other words, do not enter clc or select Edit > Clear 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. To use the incremental search feature in the Command Window, follow these steps:
Position the cursor where you want the search to begin.
Begin the incremental search using one of the following, depending on your setting for the Command Window key bindings. (Available from File > Preferences > Keyboard.)
If you set the preference to MATLAB Standard (Emacs), press Ctrl+S
If you set the preference to Windows , press Ctrl+Shift+S
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).

In the Inc Search field, type the text you want to find. For example, look for Boston.
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.
If you mistype in the Inc Search field, use the Back Space key to remove the last letters and make corrections.
After finding the bo, you can press Ctrl+W to complete that word. In this example, Boston appears in the Inc Search field.
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
If MATLAB beeps, it means either that the text was not found, or the search wrapped past the end (or beginning) of the Command Window and continued at the beginning (or end).
When the text is not found, Failing appears in the incremental search field. Modify the search term in the incremental search field and try again. Use Ctrl+G to automatically remove characters back to the last successful search. For example, if plode fails, Ctrl+G removes the de from the search term because plo does exist in the Command Window.
To end the incremental search, press Esc (escape) or Enter, or any other key that is not a character or number.
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 — see Performing an Incremental Search in the Editor.
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.

![]() | Controlling Output in the Command Window | Preferences for the Command Window | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |