Alexey Starinsky
Alexey Starinsky

Reputation: 4339

Space after 'if', 'while', 'catch' etc.. with clang-format

Cannot figure out that option adds the space after if, while, catch, etc...

Currently my .clang-format file produce this:

        while(true)
        {
            if(flushedCount == count)
            {
                break;
            }
        }

Upvotes: 7

Views: 4042

Answers (1)

Paweł Bylica
Paweł Bylica

Reputation: 4235

The clang-format configuration option controlling space after if, while, catch and other control statements is called SpaceBeforeParens.

SpaceBeforeParens: ControlStatements

From clang-format 8 documentation:

SpaceBeforeParens (SpaceBeforeParensOptions)

Defines in which cases to put a space before opening parentheses.

Possible values:

  • [...]
  • SBPO_ControlStatements (in configuration: ControlStatements) Put a space before opening parentheses only after control statement keywords (for/if/while...).
  • [...]

Upvotes: 8

Related Questions