Next: , Previous: , Up: Comments   [Contents][Index]

26.5.2 Multiple Lines of Comments

If you are typing a comment and wish to continue it to another line, type M-j or C-M-j (comment-indent-new-line). This breaks the current line, and inserts the necessary comment delimiters and indentation to continue the comment.

For languages with closing comment delimiters (e.g., ‘*/’ in C), the exact behavior of M-j depends on the value of the variable comment-multi-line. If the value is nil, the command closes the comment on the old line and starts a new comment on the new line. Otherwise, it opens a new line within the current comment delimiters.

When Auto Fill mode is on, going past the fill column while typing a comment also continues the comment, in the same way as an explicit invocation of M-j.

To turn existing lines into comment lines, use M-; with the region active, or use M-x comment-region as described in the preceding section.

You can configure C Mode such that when you type a ‘/’ at the start of a line in a multi-line block comment, this closes the comment. Enable the comment-close-slash clean-up for this. See Clean-ups in The CC Mode Manual.