Since there's a lot of normal text in comments and string literals, CC Mode provides features to edit these like in text mode. The goal is to do it seamlessly, i.e., you can use auto fill mode, sentence and paragraph movement, paragraph filling, adaptive filling etc. wherever there's a piece of normal text without having to think much about it. CC Mode keeps the indentation, fixes suitable comment line prefixes, and so on.
You can configure the exact way comments get filled and broken, and where Emacs does auto-filling (see see Custom Filling and Breaking). Typically, the style system (see Styles) will have set this up for you, so you probably won't have to bother.
Line breaks are by default handled (almost) the same regardless of whether they are made by auto fill mode (see Auto Fill), by paragraph filling (e.g., with M-q), or explicitly with M-j or similar methods. In string literals, the new line gets the same indentation as the previous nonempty line.1.
The formatting of the starters (
/*) and enders (
block comments are kept as they were before the filling. I.e., if
either the starter or ender were on a line of its own, then it stays
on its own line; conversely, if the delimiter has comment text on its
line, it keeps at least one word of that text with it on the line.
This command is the replacement for
fill-paragraph in CC Mode
c-indent-new-comment-line. In normal code it's indented like
newline-and-indentwould do. In macros it acts like
newline-and-indentbut additionally inserts and optionally aligns the line ending backslash so that the macro remains unbroken. See Custom Macros, for details about the backslash alignment. In a string, a backslash is inserted only if the string is within a macro2.
This function is not bound to a key by default, but it's intended to be
used on the RET key. If you like the behavior of
newline-and-indent on RET, you should consider switching to
this function. See Sample Init File.
c-context-line-breakis to RET. I.e., it works just like
c-context-line-breakbut leaves the point before the inserted line break.