Main Content

Editor/Debugger Preferences

You can customize the visual display and functionality of the Editor, Live Editor, and Debugger using Editor/Debugger preferences.

General Preferences for the Editor/Debugger

You can specify which editor MATLAB® uses, as well as how the MATLAB Editor and Live Editor behave 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™.

PreferenceUsage

Editor

Select which editor you want the MATLAB desktop to use when you edit a file:

  • MATLAB Editor

  • Text editor

If you select Text editor, specify the full path for the editor application you want to use, such as Emacs or vi. For example, c:/Applications/Emacs.exe.

This preference applies only to plain text files such as files with a .m or .txt extension.

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.

Select Display full path of files in the Editor to display the full path of files open in the MATLAB Online Editor and Live Editor. The path displays at the top of each open file.

Automatic file changes

Select Save changes upon clicking away from a file if you want the Editor and Live Editor to automatically save changes to a file when you click away from the file. For the changes to be automatically saved upon clicking away, you must have already saved the file at least once.

In MATLAB Online, this preference is located under MATLAB > Editor/Debugger > Saving.

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 <CR>) to the end of a file automatically if the last line in the file is not empty.

This preference applies only to plain text files such as files with a .m or .txt extension.

Debugging

Specify when to show the inline Step in button using the Show inline Step in buttons option.

  • Select Always to show the button for all functions and scripts.

  • Select For user-defined functions to show the button only for user-defined functions and scripts.

  • Select Never to never show the button.

Select Open Debugger panel automatically to open the Debugger panel automatically when MATLAB enters debug mode. Clear Open Debugger panel automatically to disable opening the Debugger panel automatically. This option is available in MATLAB Online only.

Editor/Debugger Display Preferences

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.

PreferenceUsage
General display options

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.)

Code snippet with the cursor on the variable n and a data tip showing the data type and value of n

For details, see View Variable Value.

This preference does not apply in the Live Editor.

Select an option from Live Editor default view to specify the default location of output when creating new live scripts:

  • Output on right — Output displays to the right of the code. Each output displays with the line that creates it. This option is ideal when writing code.

    To disable the alignment of output to code when output is on the right, right-click the output section and select Disable Synchronous Scrolling.

  • Output inline — Output displays inline with the code. Each output displays underneath the line that creates it. This option is ideal for sharing.

Select Focus outputs using keyboard when output is inline to enable using the up arrow and down arrow keys to move focus to the output when output is inline.

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 Color at the specified column (Placement) in the Editor.

For details, see Change the Right-Side Text Limit Indicator.

This preference does not apply in the Live Editor.

Editor/Debugger Tab Preferences

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.

In MATLAB Online, these preferences are located under MATLAB > Editor/Debugger > Indenting.

OptionUsage
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 automatic indenting. To set automatic indenting preferences, see 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 automatic indenting preferences when you position the cursor in a line or select a group of lines, and then press the Tab key. To set automatic indenting preferences, see Editor/Debugger Language Preferences.

If you select this preference, you cannot insert tabs within a line.

Editor/Debugger Language Preferences

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.

In MATLAB Online, these preferences are located under Editor/Debugger > MATLAB Language and Editor/Debugger > Other Languages.

Not all preferences are available for all languages.

PreferenceUsage
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.

To change the MATLAB syntax highlighting colors, click Set syntax colors. For more information, see Syntax Highlighting.

To change syntax highlighting colors for all other languages, select from the options under Enable 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.

Automatic variable and function renaming tooltip prompting you to press Shift+Enter to rename all instances of a variable

For details on when MATLAB prompts you, see Automatically Rename All Variables or Functions 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:

  • Start from beginning of line when the absolute width of the comments is important. For example, set 75 columns from the start of the line to match the width that fits on a printed page when you use the default font for the Editor.

  • Start from beginning of comment when comments are indented, and you want each block of comments to have a consistent indent and width.

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 Code.

Indenting

Select Apply smart indenting while typing to automatically:

  • Indent the body of loops within the start and end of the loop statement.

  • Align subsequent lines with lines you indent using tabs or spaces.

  • Indent functions as specified with the Function indenting format option.

You also can manually apply automatic indenting after you type the code. For more information, see Indent Code.

Select an option from Function indenting format (MATLAB Language only) to specify how functions indent in the Editor and Live Editor, as follows:

  • Classic — The Editor and Live Editor align the function code with the function declaration.

    Function containing code and a nested function, with the code for each function aligned to the function declaration.

  • Indent nested functions — The Editor and Live Editor indent the function code within a nested function.

    Function containing code and a nested function, with the code in the nested function indented from the nested function declaration.

  • Indent all functions — The Editor and Live Editor indent the function code for both main and nested functions.

    Function containing code and a nested function, with the code for each function indented from their function declaration.

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.

Editor/Debugger Code Folding Preferences

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 Fold Code.

Code folding preferences do not apply in the Live Editor.

OptionUsage
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 InitiallySpecifies whether the corresponding Programming Construct displays collapsed (folded) the first time that you open a MATLAB file.

Editor/Debugger Backup Files Preferences

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.

PreferenceUsage

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 optionsSave 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 Untitled.asv.

When there is more than one untitled file, each additional file is saved to Untitledn.asv (where n is an integer value).

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.

To ensure clear and current backup-to-file relationships if you disable this option, when you rename or remove a file, consider deleting or renaming the corresponding backup file.

File name

Select the naming convention that you want MATLAB to use for autosave files. For example:

  • If you specify Replace extension with: asv, the backup file for filename.m is filename.asv

  • If you specify Append file name with: ~, the backup file for filename.m is filename.m~

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.

If you edit a file in a read-only folder and the back up Location is Source file directories, then the Editor does not create a backup copy of the file.

For more information about automatically creating backup copies of modified files in the Editor, see Save and Back Up Code.

Editor/Debugger Autoformatting Preferences

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.

PreferenceUsage

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.

Editor/Debugger Automatic Completions Preferences

You can change how MATLAB suggests and completes names in the Editor, Live Editor, and App Designer. You also can change whether MATLAB automatically completes block endings, parentheses, quotes, comments, character vectors, and strings in the Editor, Live Editor, and App Designer.

On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger > Automatic Completions, and then adjust preference options as described in this table.

PreferenceUsage

Suggestions and completions

Select Show suggestions automatically to automatically show suggestions as you type in the Editor, Live Editor, and App Designer. Clear Show suggestions automatically to show suggestions only when you press Ctrl+Space or press the Tab key.

For more information, see Check Syntax as You Type.

Select Use tab to show suggestions (in addition to ctrl+space) to show suggestions when you press the Tab key in the Editor, Live Editor, and App Designer. Clear Use tab to show suggestions (in addition to ctrl+space) to show suggestions only when you press Ctrl+Space.

For more information, see Check Syntax as You Type.

Select Use right arrow to accept suggestions (in addition to tab and enter) to accept suggestions using the Right Arrow key in the Editor, Live Editor, and App Designer. Clear Use right arrow to accept suggestions (in addition to tab and enter) to accept suggestions using the Tab and Enter keys.

For more information, see Check Syntax as You Type.

Autocoding options

Select Enable autocoding to enable autocoding options in the Editor, Live Editor, and App Designer. Once enabled, options can be enabled or disabled individually.

Autocomplete pairs

  • Select Parentheses ( ) to autocomplete parentheses.

  • Select Curly braces { } to autocomplete curly braces.

  • Select Square brackets [ ] to autocomplete square brackets.

  • Select Single quotes (' ') to autocomplete single quotes.

  • Select Double quotes (" ") to autocomplete double quotes.

Autocomplete on new line

  • Select Comments (%) to automatically split comments when you press Enter. For example, place your cursor after the first period in the comment below and press Enter.

    % This is my first comment. This is my second comment.
    The text after the cursor moves to a new line and the Editor adds a percent (%) symbol to the beginning of the new line.
    % This is my first comment.
    % This is my second comment.

  • Select Character vectors (' ') to automatically split character vectors when you press Enter. For example, place your cursor after the word Random in the character vector below and press Enter.

    title('Mean of Random Uniform Data')
    The Editor splits the character vector into two character vectors across two lines.
    title(['Mean of Random' ...
        ' Uniform Data'])

  • Select Strings (" ") to automatically split strings when you press Enter. For example, place your cursor after the word long in the string below and press Enter.

    exist("exceptionally_long_file_name.txt")
    The Editor splits the string into two strings on two lines.
    exist("exceptionally_long" + ...
        "_file_name.txt")

  • Select Parentheses () to automatically split parentheses when you press Enter. For example, place your cursor after the number 10 and the comma in the command below and press Enter.

    plot(x,y,'--gs','LineWidth',2,'MarkerSize',10,'MarkerEdgeColor','b')
    The Editor splits the command onto two lines.
    plot(x,y,'--gs','LineWidth',2,'MarkerSize',10, ...
        'MarkerEdgeColor','b')

Autocomplete block endings

  • Select Control flow statements (if, for, etc.) to autocomplete 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 autocomplete function and class definitions. To autocomplete a definition, enter either function or class and press Enter.

Editor/Debugger Find and Replace Preferences

You can change the behavior of the Find and Replace dialog box, including disabling wrap-around search, MATLAB Online.

On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger > Find and Replace, and then adjust preference options as described in this table.

Find and replace preferences are not available in installed versions of MATLAB.

OptionUsage
Search behavior

Select Wrap around to continue searching from the start of the document when the end of the document is reached, until the whole document has been searched.

Select Move cursor while typing to move the cursor to the first result while typing the search phrase. Clear Move cursor while typing to move the cursor only after the entire search phrase has been entered.

Select Highlight search results to highlight all search results in the document.

Search text

Select Use selection for initial search text to use the current selection as the initial search text.

Select Use nearest word for initial search text to use the word closest to the cursor position as the initial search text.

Search history

Select Persist search and replace history across sessions to save the search and replace history and the Find and Replace dialog box state across sessions. Clear Persist search and replace history across sessions to disable saving any search and replace data, including the Find and Replace dialog box state.

Position

Select Position dialog box above document to position the Find and Replace dialog box in added space above the document when the dialog box is open. When the Find and Replace dialog box is closed, the space is removed. This added space prevents the dialog box from covering part of the document when the dialog box is open.

Editor/Debugger Indenting Preferences

You can change the size of tabs and indents and the behavior of automatic indenting in the MATLAB Online Editor and Live Editor. To enable or disable automatic indenting, see Editor/Debugger Language Preferences.

On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger > Indenting, and then adjust preference options as described in this table.

Indenting preferences are not available in installed versions of MATLAB.

OptionUsage
Tabs and indents

Specify Tab size to determine the amount of space inserted when you press the Tab key.

When you change the Tab size value, the tab size changes for existing lines in that file, unless you also select Tab key inserts spaces.

Specify Indent size for automatic indenting.

Select Tab key inserts spaces to insert a series of spaces when you press the Tab key. Otherwise, a tab acts as one space whose length is equal to Tab size.

Select Tab key applies smart indenting to automatically indent lines according to automatic indenting preferences when you position the cursor in a line or select a group of lines and then press the Tab key.

If you select this preference, you cannot insert tabs within a line.

Smart indentingSelect Smart indenting formats entire document to indent the entire document when automatically indenting in the MATLAB Online Editor and Live Editor. Clear this option to indent only the current line or selection.
Select Add whitespace to empty lines to indent empty lines when automatically indenting in the MATLAB Online Editor and Live Editor by adding white space to those lines. Clear this option to indent only lines that are not empty.
Select Remove automatically inserted whitespace while typing to remove white space added by automatic indenting while typing in the MATLAB Online Editor and Live Editor. Clear this option to leave added white space as is.

Editor/Debugger Saving Preferences

You can specify if and when MATLAB Online saves files automatically.

On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger > Saving, and then adjust preference options as described in this table.

Saving preferences are not available in an installed version of MATLAB.

PreferenceUsage

Autosave options

Select Save files periodically to have MATLAB Online periodically save the files you are currently editing.

In the Every: n minutes field, specify how often you want MATLAB to save the files you are editing. By default, MATLAB saves files every 1 minute.

Select Save changes upon clicking away from a file if you want the Editor and Live Editor to automatically save changes to a file when you click away from the file. For the changes to be automatically saved upon clicking away, you must have already saved the file at least once.

In an installed version of MATLAB, this preference is located under MATLAB > Editor/Debugger.