What is indented in c

C ++ formatting conventions for EditorConfig

  • 2 minutes to read

The Visual Studio C ++ formatter has an extensive set of configurable settings that can be applied globally. To specify C ++ formatting settings for a specific workspace, use clangformat or EditorConfig. Both Visual Studio and Visual Studio Code have built-in EditorConfig support for each of the Visual Studio C ++ global formatting settings, with the EditorConfig settings taking precedence. This means that you can add EditorConfig files to your workspace to configure the C ++ formatting at a more granular level and to enforce a consistent code format for all users who contribute to the project.

C ++ formatting conventions

EditorConfig settings for C ++ formatting is prepended. The following is an example of what the EditorConfig file might look like:

The remainder of this document lists all of the EditorConfig C ++ formatting settings that Visual Studio and VS Code support.

Feed settings

Indent curly braces

  • Surname:
  • Values: ,

Indent each line relative to

  • Surname:
  • Values:
    • - When entering a new line, it is drawn in relative to the outermost opening bracket.
    • - When entering a new line, it is drawn in relative to the innermost opening bracket.
    • - When entering a new line, it is indented relative to the beginning of the current statement.

Align new lines within brackets when entering them

  • Surname:
  • Values:
    • - Align content with opening brackets.
    • - Indent new lines.

Do not use the setting for aligning new lines within parentheses in existing code.

  • Surname:
  • Values: ,

Indent content

  • Surname:
  • Values: ,

Draw in case names

  • Surname:
  • Values: ,

Indent the following curly braces on the case statement

  • Surname:
  • Values: ,

Indent curly brackets of lambda functions used as parameters

  • Surname:
  • Values: ,

Position of the goto designations

  • Surname:
  • Values:
    • - Indent once to the left
    • - Move to the leftmost column
    • - Leave indented

Position of preprocessor directives

  • Surname:
  • Values:
    • - Indent once to the left
    • - Move to the leftmost column
    • - Leave indented

Indent access specifier

  • Surname:
  • Values: ,

Indent namespace content

  • Surname:
  • Values: ,

Maintain indentation of comments

  • Surname:
  • Values: ,

Line break settings

Position of opening curly braces for namespaces

  • Surname:
  • Values:
    • - Move to a new line
    • - Leave on the same line, but add a leading space
    • - Do not change position automatically

Position of opening curly braces for types

  • Surname:
  • Values:
    • - Move to a new line
    • - Leave on the same line, but add a leading space
    • - Do not change position automatically

Position of opening curly braces for functions

  • Surname:
  • Values:
    • - Move to a new line
    • - Leave on the same line, but add a leading space
    • - Do not change position automatically

Position of opening curly braces for control blocks

  • Surname:
  • Values:
    • - Move to a new line
    • - Leave on the same line, but add a leading space
    • - Do not change position automatically

Position of opening curly braces for lambda functions

  • Surname:
  • Values:
    • - Move to a new line
    • - Leave on the same line, but add a leading space
    • - Do not change position automatically

Position curly braces on separate lines

  • Surname:
  • Values: ,

Move closing curly braces for empty types to the same line as opening curly braces

  • Surname:
  • Values: ,

Move closing curly braces in empty function bodies to the same line as opening curly braces

  • Surname:
  • Values: ,

Place "catch" and similar keywords on a new line

  • Surname:
  • Values: ,

Arrange else statement on a new line

  • Surname:
  • Values: ,

Place 'while' on a new line in a do-while loop

  • Surname:
  • Values: ,

Distance settings

Space between function names and opening brackets in argument lists

  • Surname:
  • Values:
    • - insert spaces
    • - Remove spaces
    • - Do not change spaces

- Insert spaces between the brackets of an argument list

  • Name: Values:,

Insert spaces between brackets if the argument list is empty

  • Surname:
  • Values: ,

In control flow instructions, insert a space between the keyword and the opening parenthesis

  • Surname:
  • Values: ,

Insert spaces between brackets for control statement

  • Surname:
  • Values: ,

Insert spaces before opening brackets of the lambda argument list

  • Surname:
  • Values: ,

Insert spaces between brackets for C-style conversions

  • Surname:
  • Values: ,

Insert spaces after closing parenthesis of the C-style conversion

  • Surname:
  • Values: ,

Insert spaces between brackets of an expression in brackets

  • Surname:
  • Values: ,

Insert spaces before opening curly braces of a block

  • Surname:
  • Values: ,

Insert spaces between empty curly braces

  • Surname:
  • Values: ,

Insert spaces in front of opening curly braces of a uniform initialization and initializer lists

  • Surname:
  • Values: ,

Insert spaces between curly brackets of a uniform initialization and the initializer lists

  • Surname:
  • Values: ,

Keep spaces within uniform initialization and initializer lists

  • Surname:
  • Values: ,

Insert spaces before opening square brackets

  • Surname:
  • Values: ,

Insert spaces between square brackets

  • Surname:
  • Values: ,

Insert spaces in front of empty square brackets

  • Surname:
  • Values: ,

Insert spaces between empty square brackets

  • Surname:
  • Values: ,

Group square brackets together for multidimensional arrays

  • Surname:
  • Values: ,

Insert spaces between square brackets for lambda functions

  • Surname:
  • Values: ,

SpaceBetweenEmptyLambdaBrackets

  • Surname:
  • Values: ,

Insert spaces before commas

  • Surname:
  • Values: ,

Insert spaces after commas

  • Surname:
  • Values: ,

Remove spaces before and after member operators

  • Surname:
  • Values: ,

Insert spaces before colon for base in type declarations

  • Surname:
  • Values: ,

Insert spaces before colon for constructors

  • Surname:
  • Values: ,

Remove spaces in front of semicolons

  • Surname:
  • Values: ,

Insert spaces after semicolons

  • Surname:
  • Values: ,

Remove spaces between unary operators and their operands

  • Surname:
  • Values: ,

Spacing for binary operators

  • Surname:
  • Values:
    • - Insert spaces before and after binary operators.
    • - Remove spaces around binary operators.
    • - Do not change spaces around binary operators.

Spacing for assignment operators

  • Surname:
  • Values:
    • - Insert spaces around assignment operators.
    • - Remove spaces around assignment operators.
    • - Do not change spaces around assignment operators.

Pointer / reference alignment

  • Surname:
  • Values:
    • - Align left.
    • - Align centered.
    • - Align right.
    • - Leave unchanged.

Space for conditional operators

  • Surname:
  • Values:
    • - Insert spaces around conditional operators.
    • - Remove spaces around conditional operators.
    • - Do not change spaces around conditional operators.

Break options

Break options for blocks

  • Surname:
  • Values:
    • - Do not break single-line code blocks.
    • - Do not break code blocks in such a way that opening and closing curly braces are on the next line.
    • - Always use line break settings for blocks.

additional Information