Comment Styles

Source Insight adds some explicit formatting to comments. All comments inherit from the Comment parent style. The comment style hierarchy appears below.

inset_100019.png

 

Figure 3.10  The comment styles hierarchy.

Comment Heading Styles

Comment heading styles are very useful for breaking up large chunks of code with high-level comments.

Comment Heading styles are specified with a //n comment prefix, where n is a number between 1 and 4. For example:

//1 This is a Heading 1 comment

//2 This is a Heading 2 comment

//3 This is a Heading 3 comment

//4 This is a Heading 4 comment

When the comment displays, the //n at the beginning of the comment is hidden, unless the cursor is on that line. The above lines appear like this:

inset_10_1.jpg

 

If the cursor is on the line, then the //n will appear so that you can edit it.

inset_45.jpg

 

Comment Right Style

Comments that appear to the right of code are given the "Comment Right" style. For example:

inset_46.jpg

 

Single and Multi Line Comment Styles

Multi-Line comments are displayed in the Comment Multi Line style. These are any comments using the /* and */ delimiters in C/C++ and Java.

Single line comments are displayed in the Comment Line style. These include comments that start with // delimiters in C/C++ and Java.

inset_47.jpg

 

Comment Styles and Custom Languages

When you define a custom language, using the Preferences: Languages dialog box, you can specify comment or text-range types, and associate them with a style. For example, you could create a comment range that starts with (* and ends with *) and the text is formatted with the "Comment Multi Line" style. You can actually define any delimited range of text, and associate it with any style (including a non-comment style).See: Symbols and Language Parsing. and Special Language Options.