Development Environment    


You can comment the current line or a selection of lines. To select a line, click just to the left of the line. The line becomes highlighted. Drag or Shift+click to select multiple lines. Then select Comment from the Text menu, or right-click and select it from the context menu. A comment symbol, %, is added at the start of the line, and the color of the text becomes green (or the color specified for comments in Editor/Debugger preferences).

You can make any line a comment by typing a % at the beginning of it. To put a comment within a line, type % followed by the comment text; MATLAB treats all the information after the % on that line as a comment.

You can also uncomment a selected group of lines--select Uncomment from the Text menu, or right-click and select it from the context menu.

Formatting Comments.   To make comment lines in M-files wrap when they reach a certain column:

  1. Specify the maximum column number using preferences for the Editor. Under M-file formatting, set the Max width. See M-file comment formatting for details.
  2. Select contiguous comment lines that you want to limit to the specified maximum width.
  3. Select Text -> Format Selected Comments.
  1. The selected comment lines are reformatted so that no comment line in the selected area is longer than the maximum. Lines that were shorter than the specified maximum are merged to make longer lines if they are at the same level of indentation.

If you want comment lines to automatically be limited to the maximum width while you type, select the Editor preference to Autowrap comments--see M-file comment formatting.

  Appearance of an M-File Showing Balanced Delimiters