Desktop Tools and Development Environment Previous page   Next Page

M Language Preferences

Select File -> Preferences -> Editor/Debugger -> Language -> M to specify these preferences for editing M-files:

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 Colors, and the Colors preference dialog box opens, where you specify the colors used for syntax highlighting.

Syntax highlighting for M-files applies to files with the m and cdr extensions. 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/Debugger, the Colors preferences apply to all tools. For a description of syntax highlighting, see Syntax Highlighting in the Command Window documentation.

Indenting for Enter Key

Select the style of indenting you want the Editor/Debugger 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:

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 Keyboard and Indenting preferences for the Editor/Debugger--see Tabs and Indents. When indents automatically apply to a line but you do not want them on that line, use backspace (or delete selection) to move the cursor to the left. 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.   

Image of sample code showing the results of selecting the no indent preference and no manually inserted tabs. All lines are left aligned at column 0.

Example of No Indent with Tabs.   

Image of sample code showing the results of selecting the no indent preference with manually inserted tabs.

Example of Block Indent.   

Image of sample code showing the result when the block indent preference is selected. A tab was inserted at the start of line 4. Line 4 and all subsequent lines are indented, that is, are left aligned at column 5.

Example of Smart Indent.   

Image of sample code showing the result when the smart indent preference is selected.

Function Indenting Format

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

Examples of Function Indenting Format Preference.   

Image of M-file showing examples of different options for function indenting format preference.

Comment Formatting

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 for details.

For example, assume you select Autowrap comments and set the maximum width to be 75 characters, which is the width that will fit on a printed page using the default font for the Editor/Debugger. 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 Also


Previous page  Language Preferences for the Editor/Debugger C/C++ Language Preferences Next page

© 1994-2005 The MathWorks, Inc.