|On this page…|
To specify the default editor for MATLAB®:
On the Home tab, in the Environment section, click Preferences. The Preferences dialog box opens.
Select the MATLAB > Editor/Debugger node on the left pane.
In the Editor pane, click Text editor and specify a default text editor.
If you invoke the edit command while running MATLAB with the -nodisplay option, choose an appropriate text-based editor instead of the default editor specified in the Preferences dialog box. This is done differently depending on your platform.
When running MATLAB with the -nodisplay startup option, edit opens the editor specified in the EDITOR environment variable.
To display the current value of $EDITOR in MATLAB, execute the command:
When running MATLAB with the -nodisplay option (or without the DISPLAY environment variable set) on UNIX® platforms, you can find the default editor defined for your system in matlabroot/X11/app-defaults/Matlab.
You can specify the default editor or editor options by adding the following line to your own.Xdefaults file. This file is typically found in your home directory (~):
matlab*externalEditorCommand: $EDITOR -option $FILE
$EDITOR is the name of your default editor, for example, emacs. Leaving the environment variable EDITOR as $EDITOR instruct MATLAB to use your default system editor.
-option is a valid option flag you can include for the specified editor.
$FILE means the file name you type with the edit command opens in the specified editor.
After adding the line to your.Xdefaults file, run the following before starting MATLAB:
xrdb -merge ~/.Xdefaults
This assumes the .Xdefaults file is in your home directory.
For example, this code, executed from within MATLAB, opens foo in the emacs editor: