| MATLAB® | ![]() |
Select File > Preferences > Editor/Debugger to specify the preferences on the main pane, listed here. Or click the + to see additional Editor/Debugger preferences:
MATLAB Editor. Selecting MATLAB Editor means that the MATLAB® desktop uses the built-in Editor.
Text editor. To specify a text editor other than the MATLAB Editor, such as Emacs or vi, to be used when you open an M-file from within MATLAB, select Text editor. Specify the full path for the editor application you want to use.
For example, specify c:/Applications/Emacs.exe in the Text editor field, and then open a file using Open from the File menu in the MATLAB desktop. The file opens in Emacs instead of in the MATLAB Editor.
Note that even if you use another editor, Editor/Debugger preferences are still available because some of the Editor/Debugger preferences apply to other MATLAB tools.
Integrated text editor. This option appears only if you correctly registered EmacsLink with MATLAB. Select this if you want to use EmacsLink, a tool that allows you to use the Emacs editor with MATLAB debugging capabilities. EmacsLink is not supported by The MathWorks™. For details on installing, registering, and using EmacsLink, see Installing EmacsLink.
Use this preference to specify the number of files that appear in the list of most recently used files at the bottom of the File menu. You select a file from the list to open it.
On restart. To start a MATLAB session and automatically open the files that were open when you last shut down MATLAB, select the item On restart open files from previous MATLAB session. If the item is not selected and you close MATLAB when there are files open in the Editor, the next time you start MATLAB, the Editor is not opened upon startup.
See Also. From the Debug menu in the MATLAB desktop, you can select the item Open M-files when debugging.
Reload unedited files that have been externally modified. This option is useful when you edit files in the MATLAB Editor and outside of MATLAB.
With the option selected, the Editor automatically reloads another version of the file as described here. When a file is open in the Editor and the same file is also open outside of MATLAB, the Editor automatically uses the version open outside of MATLAB if you have not edited the file in the Editor.
When you clear this preference, MATLAB displays a dialog box notifying you that the current file was changed outside of MATLAB, and asks if you want to use the latest version.
Add line termination at end of line. With this preference selected, if the last line in the file is not empty, the Editor automatically adds a new empty line to the end of the file. Select this preference if you use your files with other products that expect a new line (sometimes referred to as a <CR>) at the end of the file.
Select File > Preferences > Editor/Debugger > Display to specify these preferences:
By default, a light red vertical line appears at column 75 in the Editor, providing a cue as to when a line of code becomes wider than desired, for example, for printing.

To hide the vertical line, clear the Show line at check box. To change the column at which the vertical line appears, enter the new value in the columns edit field.
The actual column number at which you set it is most useful when the preference for the Editor/Debugger font is a monospaced font. See Fonts Preferences for Desktop Tools for details.
See also Comment Formatting for information about wrapping a comment line when it reaches a specified column number.
Highlight Current Line. Select this preference to highlight the current line, that is, the row with the caret (also called the cursor). This is useful, for example, to help you see where copied text will be inserted when you paste. Then specify the color used to highlight the line.
Show line numbers. Select this item to show line numbers along the left edge of the Editor window. Showing line numbers allows you to easily use various Editor features, such as Edit > Go To Line. When you clear this item, line numbers are not shown.
Enable datatips in edit mode. Select this option to see datatips while editing an M-file. By default, datatips are not shown while editing (edit mode), although they are always shown while debugging (debug mode). In edit mode, the datatips display the values of variables in the base workspace, so this is useful for script M-files rather than function M-files. In edit mode for a function M-file, the datatip for a variable will show a value if that variable also exists in the base workspace—the datatip displays the value of the base workspace variable, not the value of the variable in the function M-file.
While you are debugging, you cannot turn off the display of datatips, and they show the value of the variables in the workspace selected in the Stack. For more information about datatips, see Viewing Values as Data tips in the Editor.
Highlight cells. Select this item to highlight the current cell, and select a color for the highlighting. Pale yellow is the default color.
Show lines between cells. Select this preference to display a faint gray horizontal line above each new cell. The line does not appear in the published M-file nor in the printed M-file.
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Tab to specify these preferences.
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. This does not apply when the preference for Tab key inserts spaces is selected.
Tab key inserts spaces. Select this item if you want a series of spaces to be inserted when you press the Tab key. If the item is not selected, a tab acts as one space whose length is determined by Tab size.
Indent size. Specify the indent size for smart indenting. See also Indenting for Enter Key.
Emacs-style Tab key smart indenting. This indenting convention is based on the style used by the Emacs editor and is similar to the Smart indent preference. With this preference selected, lines are indented according to smart indenting practices when you position the cursor in a line or select a group of lines, and then press the Tab key. You then cannot use tabs within a line.
See also these additional preferences for indenting:
Language Preferences for the Editor/Debugger for additional indenting preferences
Keyboard Preferences for key binding, tab completion, an d delimiter matching preferences
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Language to specify preferences, such as syntax highlighting, for the type of file you are editing. Language preferences apply based on the current file name extension. To specify language preferences, first select the Language. The preference dialog box displays the preferences for that language. Make changes to preferences for that language and click Apply.
As an example, when you edit a file with an .html extension, the language preferences for XML/HTML apply to that file. If you have a Java™ file open at the same time, the Java language preferences apply to the Java file.
To use the language preferences, the file name you edit must have one of the extensions shown in the File extensions list. Use the Add and Remove buttons to change the extensions associated with the selected language. Below are the default file extensions for each language. If a file has no extension (for example, a new untitled file), an M-file is assumed. For an extension other than those in the list, there is no syntax highlighting. Changes you make to the file extensions do not apply to currently open files, so close files and open them again.
Language Preference | Default File Extensions |
|---|---|
M (MATLAB M-file) | .m (uppercase or lowercase) |
TLC | .tlc |
C/C++ | .c, .cpp, .h, .hpp |
Java | .java |
XML/HTML | .xml, .xsl, .wsdl, .html, .htm, .shtml |
For details about preferences for each language, see
Keyboard Preferences for the Editor/Debugger and Command Window
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Language -> M to specify these preferences for editing M-files:
See Also — links to additional preferences, including M-Lint
Enable syntax highlighting. Select the Enable syntax highlighting check box to show colors that help you identify certain constructs like matching if/else statements. Click Set syntax colors, and the Colors preference pane opens, where you specify the colors used for syntax highlighting.
By default, syntax highlighting for M-files applies to files with the m extension. The extension can be uppercase or lowercase. Because syntax highlighting is used in the Command Window, Command History, and other tools, as well as in the Editor, the syntax highlighting colors preferences apply to all tools that use syntax highlighting. For a description of syntax highlighting, see Colors Preferences for Desktop Tools.
Select the style of indenting you want the Editor to use for M-files. The style applies when you press the Enter key to type in a new line. Examples follow, illustrating the different styles, which are
No indent — No lines are indented. Use this if you want lines to be aligned on the left or want to indent lines manually using the tab and space keys.
Block indent — Indents a line the same amount as the line above it. When you indent a line using tabs or spaces, subsequent lines automatically align with the indented line. After entering a new line, if you want to align it further to the left than would automatically happen, use Shift+Tab to move back to a previous indent level.
Smart indent — Automatically indents lines that start with keyword functions or that follow certain keyword functions. Smart indenting can help you to follow the code sequence. With Smart indent selected, you can also specify options for indenting functions—see Function Indenting Format.
The indenting style only applies to lines you enter after changing the preference; it does not affect the indenting of existing lines. To change the indenting for existing lines, use the Text menu entries for indenting. See Indenting.
For any indenting style, you can manually insert tabs at the start of a line. The tab size is specified in Tab preferences for the Editor/Debugger—see Tabs and Indents. When indents automatically apply to lines but you do not want the lines indented, use Shift+Tab to move selected lines to the left, or select and delete the unwanted spaces. If you select Smart indent and manually insert tabs, automatic smart indenting may not work properly; use the Text menu entry for Smart Indent to correct selected lines.
Example of No Indent Without Tabs.

Example of No Indent with Tabs.



If you select the Smart indent format for the Indenting for Enter Key preference, you can specify automatic indenting for function statements. For nested functions, you must use an end statement for each function statement in the file. The styles for indenting functions are
Classic — All lines align left unless you manually insert a tab or space. If you insert a space before a function line, that line automatically indents, as do subsequent lines, until the next end statement.
Indent nested functions — Automatically indents a nested function (function within a function) line. Statements within the nested function are indented further. An end statement aligns with its matching function if end appears at the start of the line.
Indent all functions — Automatically indents statements within a function or within a nested function. An end statement aligns with its matching function if end appears at the start of the line.
Examples of Function Indenting Format Preference.

Specify the Max width, that is, the maximum width, in number of columns, for M-file comments when you select the Autowrap comments preference. The maximum width also applies when you use the Wrap Selected Comments feature. See Formatting Comments in M-Files for details.
For example, assume you select Autowrap comments and set the maximum width to be 75 characters, which is the width that fits on a printed page using the default font for the Editor. When typing a comment line, as you reach the 75th column, the comment automatically continues on the next line.
See also the Right-Hand Text Limit preference for the Editor/Debugger.
See File Extensions for general Language preferences.
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Language > TLC to specify syntax highlighting preferences for editing Target Language Compiler (TLC) files. Target Language Compiler is an integral part of Real-Time Workshop®.
Select the Enable syntax highlighting check box to show colors that help you identify TLC constructs, such as commands and macros. Optionally, change the colors used for these elements.
Commands. Color for TLC commands, such as LibBlockMatrixParameter.
Comments. Color for the comment indicator, %% or /%...%/, and its associated text.
C Strings. Color for C strings.
See File Extensions for general Language preferences.
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Language to specify preferences for editing C or C++ language files.
Select the Enable syntax highlighting check box to show colors that help you identify certain C constructs, such as methods. Specify the colors used for these elements.
Show methods. Text style for methods to appear in when you type them: Bold, Italic, or Plain (no special highlighting).
Keywords. Color for keywords, such as if.
Strings. Color for terms enclosed in double quotation marks, for example, "default".
Characters. Color for terms enclosed in single quotation marks, for example, 'a'.
Comments. Color for text following the comment indicator, //, as well as for the block comment indicators, /* and */, and the code in between.
Preprocessor. Color for text following the preprocessor symbol, #.
Bad characters. Color for illegal characters.
Select the style of indenting you want the Editor to use for C/C++ files. The style applies when you press the Enter key to type in a new line. The styles of indenting are the same as those used for M-files. For details and examples, see the M-file preference for indenting.
See File Extensions for general Language preferences.
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Language > Java to specify preferences for editing Java files.
Select the Enable syntax highlighting check box to show colors that help you identify certain Java constructs, such as methods. Specify the colors used for these elements.
Show methods. Text style for methods to appear in when you type them: Bold, Italic, or Plain (no special highlighting).
Keywords. Color for keywords, such as if.
Strings. Color for terms enclosed in double quotation marks, for example, "alive".
Characters. Color for terms enclosed in single quotation marks, for example, 'a'.
Comments. Color for text following the comment indicator, //, as well as for the block comment indicators, /* and */, and the code in between.
Bad characters. Color for illegal characters.
Select the style of indenting you want the Editor to use for Java files. The style applies when you press the Enter key to type in a new line. The styles of indenting are the same as those used for M-files. For details and examples, see the M-file preference for indenting.
See File Extensions for general Language preferences.
Keyboard Preferences for the Editor/Debugger and Command Window
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Language > XML/HTML to specify syntax highlighting preferences for editing XML, XSL, WSDL, HTML, HTM, and SHTML files.
Select the Enable syntax highlighting check box to show colors that help you identify XML, WSDL, and HTML constructs, such as elements and tags. Optionally, change the colors used for these items.
Attribute Name. Color for attribute names.
Attribute Value. Color for values, such as the source for an image, for example "myimage.gif", in <img src="myimage.gif">.
CDATA Section. Color for a CDATA section in XML files.
Character. Color for characters and entities, such as the nonbreaking space,  .
Comment. Color for text contained within comment indicators, <!-- and -->.
DOCTYPE Declaration. Color for DOCTYPE declarations.
Error. Color for invalid entries, such as <+1> for font size, which is deprecated in favor of style sheets in the HTML 4.01 specification.
See the W3C® Web site http://www.w3.org/TR/html4/ for details.
Operator. Color for operators, such as the equal sign (=).
Processing Instruction Content. Color for content that will be passed from an XML file to a target application for processing.
Processing Instruction End. Color for the delimiter that signals the end of processing instructions that will be passed from an XML file to a target application.
Processing Instruction Start. Color for the delimiter that signals the beginning of processing instructions that will be passed from an XML file to a target application.
Processing Instruction Target. Color for targets to which processing instructions are to be passed from an XML file.
Tag. Color for tags and elements, such as <font> or <img>.
Select the style of indenting you want the Editor to use for XML and HTML files. The style applies when you press the Enter key to type in a new line. The styles of indenting—no indent and smart indent—work the same way as for M-files. For details and examples, see the M-file preference for indenting.
See File Extensions for general Language preferences.
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Code Folding to set preferences for hiding and revealing code in M-files, including function and class code, function and class help code, programming control blocks, and so on.
Select this option to enable code folding in M-files; clear this option to disable code folding in M-files. (Use the table that appears below this option to enable and disable code folding for selected programming constructs within an M-file.)
This option has the following effects:
If you select this option, code folding is enabled for all programming constructs that you enable in the table that appears below this option in the Preferences dialog box.
If you clear this option, code folding is disabled for all programming constructs, regardless of the programming constructs that you may have previously enabled in the table that appears below this option in the Preferences dialog box.
If you select the Enable code folding for M-files option, you can independently enable or disable code folding for individual programming constructs (function code, function help, programming control blocks, class code, and so on) by selecting or clearing the Enable check box that corresponds to each construct in the table on the Preferences dialog box. By default, code folding is enabled for all programming constructs except if/else blocks and switch/case blocks.
If you enable code folding for a programming construct, you can specify how the Editor displays that construct the first time that you open an M-file that existed prior to MATLAB version 7.5. Select or clear the Fold Initially check box associated with a construct to direct the Editor to collapse or expand the associated construct, respectively, the first time you open an M-file that existed prior to MATLAB version 7.5 (R2007b) using MATLAB version 7.5 or later.
Additional Preferences for the Editor/Debugger
Select File > Preferences > Editor/Debugger > Autosave to specify these preferences for the Editor's autosave feature.
The MATLAB Editor automatically saves a copy of the current version of the file you are editing. Clear this check box if you do not want the MATLAB Editor to automatically save the copy.
Save every n minutes. Specify how often you want the Editor to automatically save a copy of the file you are editing.
Save untitled files. Select this check box if you want the Editor to automatically save a copy of new files that you have not yet saved, which are therefore untitled. If selected, the first autosave file is Untitled.asv. If the directory already contains a file named Untitled.asv, the autosave file is named Untitled2.asv, and so on for additional unnamed files.
If the autosave feature creates Untitled.asv and you subsequently save the file as filename.m, the next autosave version is filename.asv. Untitled.asv remains until you delete it.
Automatically delete autosave files. With this preference selected, MATLAB deletes the autosave file when you close the source file in the Editor.
Specify the extension used for autosave files. The default setting for Microsoft®Windows® platforms is the extension.asv (for autosave), making the autosave file filename.asv. For Windows and UNIX platforms, you can select Replace extension with and specify any extension.
For UNIX platforms, the default is Append file with the tilde (~) character, making the autosave file filename.m~. For Windows and UNIX® platforms, you can select Append file with and specify a different string to append to the file.
Specify the full path for the directory in which autosave files are stored. By default, each autosave file is stored in the same directory as the source file, that is, the file you are editing. You can specify a single directory for all autosave files, such as a directory you create called autosave_files. For the Editor to create an autosave file, you must have write-permission for the specified location.
Additional information that relates to the Editor and preferences includes
![]() | Adding Your Own Toolboxes to the Development Environment | Preferences for M-Lint | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |