| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
As an alternative to the edit function, select File > New or Open in the MATLAB desktop or any desktop tool.
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')
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 partial path, complete path, relative path, or no path. Be aware of the following:
If you do not specify a path, the current folder is the default.
If you specify a path, the folder must exist; otherwise MATLAB returns an error.
If you specify a path and the folder exits, but the specified file does not, a prompt opens such as shown in the following image:

To create a blank file named fun.m in the specified folder, 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.
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.
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
$EDITOR is the name of your default editor, for example, emacs; leaving it as $EDITOR means your default system editor will be used.
-option is a valid option flag you can include for the specified editor.
$FILE means the file name you type with the edit command will open in the specified editor.
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
![]() | edges (TriRep) | eig | ![]() |

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 |