Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[clang-format] Feature request: ability to break after ( / before ) in control flow statements #67738

Copy link
Copy link
@emilyy-dev

Description

@emilyy-dev
Issue body actions

After searching the clang-format style options webpage, I found no option to break after an opening parenthesis or before a closing one in control flow statements (if/for/while/do while), I was hoping to be able to have a format like this

for (
    someReallyLongInit;
    someReallyLongPredicate;
    someReallyLongStep
) {
  // ...
}

if (
    someReallyLongPredicate
) {
  // ...
}

// etc.

The closest setting I could find was AlignAfterOpenBracket with BlockIndent, but that only applies to function invocations, not control flow statements (the documentation does not mention anything about it being specific to function calls, it might be worth noting that).

This formatting setting is available in IntelliJ IDEs (which I have used, hence me hoping I could find it in clang-format!), under File | Settings | Editor | Code Style | [language] | Wrapping and Braces, it has separate settings for for/if/while/do while statements (and for Java also has one for the try-with-resources statement) allowing to "Do not wrap", "Wrap if long", "Chop down if long" and "Wrap always" which control the behaviour of the parentheses and also breaking on the init/cond/iter step in the case of for, or breaking on &&s and ||s in an if/while.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.