edit - Edit or create M-file

GUI Alternatives

As an alternative to the edit function, select File > New or Open in the MATLAB® desktop or any desktop tool.

Syntax

edit
edit fun.m
edit file.ext
edit fun1 fun2 fun3 ...
edit classname/fun
edit private/fun
edit classname/private/fun
edit +packagename/classname/fun
edit('my file.m')

Description

edit opens a new editor window.

edit fun.m opens the M-file fun.m in the default editor. The fun.m file specification can include a MATLAB partialpath, complete path, relative path, or no path. Be aware of the following:

To create a blank file named fun.m in the specified directory, click Yes. To suppress the prompt, select Do not show this prompt again. To reinstate the prompt after suppressing it, open the Preferences dialog box by selecting File > Preferences > General > Confirmation Dialogs and then selecting Prompt when editing files that do not exist in the pane on the right.

edit file.ext opens the specified file.

edit fun1 fun2 fun3 ... opens fun1.m, fun2.m, fun3.m, and so on, in the default editor.

edit classname/fun, or edit private/fun, or edit classname/private/fun opens a method, private function, or private method for the named class.

edit +packagename/classname/fun opens a method for the named class in the named package.

edit('my file.m') opens the M-file my file.m in the default editor. This form of the edit function is useful when a file name contains a space; you cannot use the command form in such a case.

Remarks

To specify the default editor for MATLAB, select Preferences from the File menu. On the Editor/Debugger pane, select MATLAB Editor or specify another editor.

UNIX® Users

If you run MATLAB with the -nodisplay startup option, or run without the DISPLAY environment variable set, edit uses the External Editor command. It does not use the MATLAB Editor, but instead uses the default editor defined for your system in matlabroot/X11/app-defaults/Matlab.

You can specify the editor that the edit function uses or specify editor options by adding the following line to your own.Xdefaults file, located in ~home:

matlab*externalEditorCommand: $EDITOR -option $FILE

where

For example,

emacs $FILE

means that when you type edit foo, the file foo will open in the emacs editor.

After adding the line to your.Xdefaults file, you must run the following before starting MATLAB:

xrdb -merge ~home/.Xdefaults

See Also

open, type

  


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