Ken & Mike on the MATLAB Desktop

August 13th, 2007

Finding items in the Command Window or the Editor

In a recent post, Kristin described a lightweight way to search in the history and the file browser. The Command Window and the Editor also have a lightweight way to look for items. It’s called incremental search.

To do an incremental search you hit a couple keys and it brings up this nice little box at the bottom of the window. (Yes, I did just leave out the keys on purpose, I’ll explain in a minute.)

Incremental Search Box

Now start typing. Each key you type refines the search. Hit Ctrl-s to go to the next match and Ctrl-r to go to the previous match. This feature is very similar to search in emacs.

Fun with keys

The one complicated part is what keys do you press? Unfortunately, the answer is that depends. Different platforms use different keys to mean the same things. We try to use the key on a platform that makes the most sense. Sometimes, however the key we want to use is already in use. Sometimes, people have different expectations of keys based on other programs they use.

Because of this we have created preferences about which key bindings you use and we try to set the defaults in a way that will make most users happy. As mentioned in a previous post, the Command Window always uses the Emacs (MATLAB Classic) set of keybindings by default and the Editor uses a platform specific set. You can change these choosing “Preferences” from the “File” menu. From the Preferences dialog, select “Keyboard” and set the keybingings to the desired set.

By default on PC Ctrl-s will bring up incremental search in the Command Window and Ctrl-Shift-s will bring it up in the Editor for forward search. By default on UNIX and Mac Ctrl-s will bring up incremental search in both the Command Window and the Editor for forward search.
To do a reverse search use the above except use r instead of s.

Have Fun!

2 Responses to “Finding items in the Command Window or the Editor”

  1. Ravi replied on :

    When I enter the function “why” in the incremental search box (obtained after typing Ctrl-s), I get a message :
    Failing F Inc Search : why
    What is wrong?

  2. Jennifer replied on :

    Hi Ravi,

    Incremental search does not search the help. It searches the text that is in the Command Window or the current editor window.

    If you have not executed why in the command window or used it in the currently open m-file in the editor then incremental search will not find it.

    Thanks,
    –Jennifer

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Ken & Mike work on the MATLAB Desktop team.
  • DP: Hi i have a problem with ezplot3, i want to plot more than i curve in the same graph but hold on command...
  • Ken: Hi Arsalan, Unfortunately there is no way to get the new Editor API in older versions of MATLAB. -Ken
  • Arsalan: Hi, I am very excited about the MATLAB API for editor because right now i am working on a project and i need...
  • Johannes: Since I started using matlab-emacs some days ago I never experienced Emacslink. But I experienced some...
  • Francisco J. Beron-Vera: Hi all, I have recently learned about ViEmu (http://www.vimemu.c om) which, for Vi/Vim...
  • OysterEngineer: When I first learned of the Publish feature in MatLab, I thought it might be useful to help to...
  • Ken: Hi Herve, I’m not quite sure what you mean by “stand-alone&# 8221; mode? -Ken
  • Herve: I wonder when the publish fonction will be supported in standalone mode.
  • Mike: Ravi, What you described should work as far I understand it. Please follow up with technical support. With a...
  • Mike: @Daniel, Thanks for that note.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.