4.7 Auto-newline Insertion

When you have Auto-newline minor mode enabled (see Minor Modes), CC Mode inserts newlines for you automatically (in certain syntactic contexts) when you type a left or right brace, a colon, a semicolon, or a comma. Sometimes a newline appears before the character you type, sometimes after it, sometimes both.

Auto-newline only triggers when the following conditions hold:

You can configure the precise circumstances in which newlines get inserted (see Customizing Auto-newlines). Typically, the style system (see Styles) will have set this up for you, so you probably won’t have to bother.

Sometimes CC Mode inserts an auto-newline where you don’t want one, such as after a ‘}’ when you’re about to type a ‘;’. Hungry deletion can help here (see Hungry Deletion of Whitespace), or you can activate an appropriate clean-up, which will remove the excess whitespace after you’ve typed the ‘;’. See Clean-ups for a full description. See also Electric Keys and Keywords for a summary of clean-ups listed by key.


Footnotes

(12)

A literal is defined as any comment, string, or preprocessor macro definition. These constructs are also known as syntactic whitespace since they are usually ignored when scanning C code.