Change Default Editor

Set Default Editor

To specify the default editor for MATLAB®:

  1. On the Home tab, in the Environment section, click Preferences. The Preferences dialog box opens.

  2. Select the MATLAB > Editor/Debugger node on the left pane.

  3. In the Editor pane, click Text editor and specify a default text editor.

Set Default Editor in '-nodisplay' mode

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.

Mac Platforms

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:

!printenv EDITOR

UNIX Platforms

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:

edit foo
Was this topic helpful?