You can customize the visual display and functionality of the Editor, Live Editor, and Debugger using Editor/Debugger preferences.
You can specify which editor MATLAB® uses, as well as how the MATLAB Editor and Live Editor behaves under various circumstances.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger, and then adjust preference options as described in the table
below.
Some general preferences are not available in MATLAB Online™.
Preference | Usage |
---|---|
Editor | Select which editor you want the MATLAB desktop to use when you edit a file:
If you select Text
editor, specify the full path for the editor
application you want to use, such as Emacs or vi. For example,
This
preference only applies to plain text files such as files with a
|
Most recently used file list | In the Number of entries field, type the number of files that you want to appear in the list of recently used files at the bottom of the File menu. |
Opening files in editor | Select On restart reopen files from previous MATLAB sessions if you want the Editor and the files it contained during your last MATLAB session to reopen when you restart MATLAB. |
Select Automatically open files when MATLAB reaches a breakpoint to open a running program file when MATLAB encounters a breakpoint in that file. | |
Automatic file changes | Select Save changes upon clicking away from a file if you want the Editor to automatically save changes to a file in the Editor when you click away from the Editor. For the changes to be automatically saved upon clicking away from the Editor, you must have already saved the file at least once. |
Select Reload unedited files that have been externally modified if you want the Editor to automatically reload the version of a file that you opened and edited outside of MATLAB when the file currently open in the Editor has no unsaved changes. | |
Select Add line termination at end of
file to have MATLAB add a new empty line (sometimes referred to as a
This preference only applies to plain text
files such as files with a | |
Debugging in the Live Editor | Select Only show Step in button for user-defined functions to have the Live Editor only step into user-defined functions and scripts. To have the Live Editor step into MathWorks® functions as well, clear the option. |
In MATLAB Online, to have MATLAB suggest and complete names automatically when you type the first few characters of the name in the Editor, Live Editor, and App Designer, in the Suggestions and completions in Editor, Live Editor, and App Designer section, select Show automatically. To have MATLAB suggest and complete names only after you press the Tab key select Show on tab.
You can change the appearance of the Editor and Live Editor.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger > Display, and then adjust preference options as described in the table
below.
Preference | Usage |
---|---|
General display option | Select Highlight Current Line and select a color to highlight the row with the cursor (also called the caret). This preference does not apply in the Live Editor. |
Select Show line numbers to display line numbers along the left edge of the Editor and Live Editor window. | |
Select Enable data tips in edit mode to display data tips when you are editing a MATLAB code file. (Data tips are always enabled in debug mode.) For details, see View Variable Value. This preference does not apply in the Live Editor. | |
Select Display the Open as a Live Script banner if you want the Open as a Live Script banner to appear at the top of documents in the Editor. | |
Right-hand text limit | Select Show line to display a vertical line with the specified Width and Color at the specified column (Placement) in the Editor. For details, see Right-Side Text Limit Indicator. This preference does not apply in the Live Editor. |
You can specify the size of tabs and indents and details about how tabs behave in the Editor and Live Editor.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger > Tab, and then adjust preference options as described in the table
below.
Option | Usage |
---|---|
Tab size | Specify the amount of space inserted when you press the Tab key. When you change the Tab size, it changes the tab size for existing lines in that file, unless you also select Tab key inserts spaces. |
Indent size | Specify the indent size for smart indenting. Smart indenting is one of the Editor/Debugger Language Preferences. |
Tab key inserts spaces | Select to insert a series of spaces when you press the Tab key. Otherwise, a tab acts as one space whose length is equal to the Tab size. |
Emacs-style Tab key smart indenting | Specifies an indenting style similar to the style that the Emacs editor uses. Lines indent according to smart indenting preferences when you position the cursor in a line or select a group of lines, and then press the Tab key. Smart indenting is one of the Editor/Debugger Language Preferences. If you select this preference, you cannot insert tabs within a line. |
You can specify how various languages appear in the Editor and Live Editor. MATLAB applies language preferences based on the file extension of the file that is open.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger > Language, and then adjust preference options as described in the table below.
To set language preferences in MATLAB
Online, select Editor/Debugger > MATLAB Language or Editor/Debugger > Other Languages.
Not all preferences are available for all languages. In addition, some language preferences do not apply in the Live Editor and are not available in MATLAB Online.
Preference | Usage |
---|---|
Language | Select the language for which you want to set preferences. |
Syntax highlighting | Select Enable syntax highlighting to have the Editor and Live Editor use different colors for different language constructs. Then, adjust the colors you want to use for each language element. Access color options for the MATLAB language by clicking Set syntax colors. For all other languages, color options appear under Enable syntax highlighting. For details, see Syntax Highlighting. |
Variable and function renaming MATLAB Language only | Select Enable automatic variable and function renaming to have MATLAB prompt you to rename all instances of a function or variable in a file when you rename a function or variable. For details on when MATLAB prompts you, see Automatically Rename All Functions or Variables in a File. |
Comment formatting MATLAB Language only | In the Maximum column width field, enter the maximum number of characters you want to allow in a line of comments, and then select where you want counting to begin. Consider selecting:
|
Select Wrap comments automatically while typing to automatically wrap comments at the Maximum column width value when you type comments in an Editor or Live Editor document. If you clear this option, you can still wrap comments manually, as described in Add Comments to Programs. | |
Indenting | Select Apply smart indenting while typing to automatically:
This is called smart indenting. You also can manually apply smart indenting after you type the code. For more information, see Indenting Code. |
Select an option from Function Indenting Format (MATLAB Language only) to specify how functions indent in the Editor and Live Editor, as follows:
For more information and examples of each indenting format, see Indenting Code. | |
File extensions | Add one or more file extensions to associate with the Language. The preferences you set for that language apply to all files with the listed extensions. |
Code folding enables you to expand and collapse blocks of MATLAB code that you want to hide when you are not currently working on them.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger > Code Folding, and then adjust preference options as described in the table
below.
For examples and detailed information about code folding, see Code Folding — Expand and Collapse Code Constructs.
Code folding preferences do not apply in the Live Editor.
Option | Usage |
---|---|
Enable Code Folding | Specifies whether you want code folding enabled for the programming constructs that have their corresponding Enable check box selected. |
Enable | Specifies whether you want code folding enabled for the corresponding Programming Construct. If you select this option for any construct, but clear the Enable Code Folding option, the construct will not have code folding enabled. |
Fold Initially | Specifies whether the corresponding Programming Construct displays collapsed (folded) the first time that you open a MATLAB file. |
You can specify if, when, and how you want MATLAB to automatically back up files that are open in the Editor.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger > Backup Files, and then adjust preference options as described in the table
below.
Backup files preferences do not apply in the Live Editor and are not available in MATLAB Online.
Preference | Usage |
---|---|
Automatically create backup files while working in the MATLAB Editor | Select to have MATLAB automatically save a copy of the files you are currently editing. |
Save options | Save the backup every: n
minutes specifies how often you want MATLAB to save a copy of the file you are editing. |
Save untitled files saves a copy of
new, untitled, files to When there is more than one untitled file, each
additional file is saved to For details, see Backing Up Files. | |
Close options | Automatically delete backup files when the Editor closes directs MATLAB to delete the backup file when you close the source file in the Editor. |
File name | Select the naming convention you want MATLAB to use for autosave files. For example:
|
Location | Source file directories specifies that you want backup files stored in the same folder as the files being edited. Single directory specifies that you want autosave files stored in a single folder. Specify the full path to that folder and be sure you have write permissions for it. |
You can quickly format live scripts and functions using autoformatting markup in the Live Editor. You can enable and disable autoformatting as a whole, or as individual options.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger > Autoformatting, and then adjust preference options as described in this table.
Autoformatting preferences do not apply in the Editor.
Preference | Usage |
---|---|
Enable autoformatting in Live Editor | Select to enable autoformatting options in the Live Editor. Once enabled, options can then be enabled or disabled individually. |
Text format | Select *italic*, **bold** to enable bold and
italic formatting using asterisks (* ). |
Select _italic_, __bold__ to enable bold and
italic formatting using underscores (_ ). | |
Select `monospace`, |monospace| to enable monospace autoformatting. | |
Section break | Select %%, ***, or --- for section break to
enable inserting section breaks by entering %% ,
*** , or --- and then
Enter. |
Select %% text for section break and heading
to enable inserting section breaks with heading 1 style headings by
entering %%text and then
Enter. | |
Insert Options | Select $LaTeX$ for LaTeX equation to enable
converting LaTeX expressions into equations using
the format $LaTeX$ . |
Select URL for hyperlink to enable converting internet paths automatically to hyperlinks. | |
Select <URL> for hyperlink to enable
converting internet paths to hyperlinks using the format
<URL> . | |
Select [Label](URL) for labeled hyperlink to
enable converting internet paths to labeled hyperlinks using the
format [Label](URL) . | |
Select (TM), (SM), (R), and (C) for trademark, service
mark, and copyright symbols to enable inserting
trademark and copyright symbols (™, ℠, ®, and ©) using the format
(TM) , (SM) ,
(R) , and (C) . | |
Text Style | Select #text for title to enable inserting
titles using the format #text . |
Select ##text, ###text, or ####text for
heading to enable inserting headings using the format
##text for heading 1,
###text for heading 2, or
####text for heading 3. | |
Select Automatic bulleted lists (*, +, or -)
to enable creating bulleted lists by entering * ,
+ , or - followed by a
space. | |
Select Automatic numbered lists (1., 2.,
etc.) to enable creating numbered lists by entering
1. , 2. , and so on, followed by a space. |
For more information about autoformatting in the Live Editor, see Autoformatting.
When you enter code in the Live Editor or in App Designer, MATLAB autocompletes block endings, parentheses, and quotes. MATLAB also autocompletes comments, character vectors, and strings when split across two lines. You can enable and disable autocoding as a whole, or as individual options.
On the Home tab, in the Environment
section, click
Preferences. Select Editor/Debugger > Autocoding, and then adjust preference options as described in this table.
Autocoding preferences do not apply in the Editor, except in MATLAB Online. In MATLAB Online, the Editor behaves the same as the Live Editor and App Designer.
Preference | Usage |
---|---|
Enable autocoding in Live Editor and App Designer | Select to enable autocoding options in the Live Editor and in App Designer. Once enabled, options can be enabled or disabled individually. |
Autocomplete parentheses | Select Parentheses ( ) to enable autocompletion of parentheses. |
Select Curly braces { } to enable autocompletion of curly braces. | |
Select Square brackets [ ] to enable autocompletion of square brackets. | |
Autocomplete quotes | Select Single quotes (' ') to enable autocompletion of single quotes. |
Select Double quotes (" ") to enable autocompletion of double quotes. | |
Autocomplete when splitting | Select Comments (%) to enable autocompletion of comments when split across two lines. For example, pressing Enter with your cursor after the period in the comment % This is my first comment. This is my second comment. % This is my first comment. % This is my second comment. |
Select Character vectors (' ') to
enable autocompletion of character vectors when split across two
lines. For example, pressing Enter with your
cursor after the word title('Mean of Random Uniform Data') title(['Mean of Random' ... ' Uniform Data']) | |
Select Strings (" ") to enable
autocompletion of strings when split across two lines. For
example, pressing Enter with your cursor after
the word exist("exceptionally_long_file_name.txt") exist("exceptionally_long" + ... "_file_name.txt") | |
Select Parentheses () to enable autocompletion of parentheses when split across two lines. For example, pressing Enter with your cursor after the number 10 and the comma in the command plot(x,y,'--gs','LineWidth',2,'MarkerSize',10,'MarkerEdgeColor','b') plot(x,y,'--gs','LineWidth',2,'MarkerSize',10, ... 'MarkerEdgeColor','b') | |
Autocomplete block endings | Select Control flow statements (if, for, etc.) to enable autocompletion of control flow statements. To autocomplete a statement, enter the statement and press Enter. For a list of control flow statements, see Loops and Conditional Statements. |
Select Function and class definitions
to enable autocompletion of functions and class definitions. To
autocomplete a definition, enter either
|