ccmode: Comment Commands

 
 4.2 Comment Commands
 ====================
 
 ‘C-c C-c’ (‘comment-region’)
      This command comments out the lines that start in the region.  With
      a negative argument, it does the opposite: it deletes the comment
      delimiters from these lines.  See(emacs)Multi-Line Comments,
      for fuller details.  ‘comment-region’ isn’t actually part of CC
      Mode; it is given a CC Mode binding for convenience.
 
 ‘M-;’ (‘comment-dwim’ or ‘indent-for-comment’ (1))
      Insert a comment at the end of the current line, if none is there
      already.  Then reindent the comment according to ‘comment-column’
      (See(emacs)Options for Comments) and the variables below.
      Finally, position the point after the comment starter.  ‘C-u M-;’
      kills any comment on the current line, together with any whitespace
      before it.  This is a standard Emacs command, but CC Mode enhances
      it a bit with two variables:
 
       -- User Option: c-indent-comment-alist
           This style variable allows you to vary the column that ‘M-;’
           puts the comment at, depending on what sort of code is on the
           line, and possibly the indentation of any similar comment on
           the preceding line.  It is an association list that maps
           different types of lines to actions describing how they should
           be handled.  If a certain line type isn’t present on the list
           then the line is indented to the column specified by
           ‘comment-column’.
 
           See the documentation string for a full description of this
           variable (use ‘C-h v c-indent-comment-alist’).
 
       -- User Option: c-indent-comments-syntactically-p
           Normally, when this style variable is ‘nil’, ‘M-;’ will indent
           comment-only lines according to ‘c-indent-comment-alist’, just
           as it does with lines where other code precede the comments.
           However, if you want it to act just like <TAB> for
           comment-only lines you can get that by setting
           ‘c-indent-comments-syntactically-p’ to non-‘nil’.
 
           If ‘c-indent-comments-syntactically-p’ is non-‘nil’ then
           ‘c-indent-comment-alist’ won’t be consulted at all for
           comment-only lines.
 
    ---------- Footnotes ----------
 
    (1) The name of this command varies between (X)Emacs versions.