MATLAB Community

MATLAB, community & more

Moving between functions within a file

When you’re writing a big M-file, you often end up with a large number of subfunctions or nested functions. Moving between them can be a pain though unless you know some tricks.

First, there is a function dropdown on the Editor’s toolbar. It shows the names of all functions (including subfunctions and nested functions) in alphabetical order, and you can click on a function name to jump to its declaration in the file.

FunctionDropdown.jpg

Next, you can use the Editor’s Go To dialog (accessible from the Go menu) to see all the functions in your file. Using the table, it is possible to sort the functions either by name or by line number.

Editor Go To dialog

Finally, if you want to get more information about a function that you are calling in your code, you can use Open Selection (CTRL+D with Windows keybindings) to quickly jump to where the function is defined. You don’t actually need to select the function as long as your caret is within the function name, and Open Selection works even if the function lives in a separate file. Note that you can then use the Back button on the Editor toolbar to quickly jump back to the place in the code where the function is used!

Using Open Selection

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。