Sumith1896
Sumith1896

Reputation: 23

How do I get one statement of C++ in one line always? (formatting/clang-format)

EDIT: Open to solutions without clang-format

I want to get the following in one line using clang-format:

    cout << "1"

        << " " << i << endl;

I have a large codebase I'm dealing with, let me know how it can be done!

I have tried all the "Penalty*" params in clang-format, they don't seem to help with us. My column limit is also very large.

Let me know if this is possible.

Upvotes: 1

Views: 153

Answers (1)

Eric Backus
Eric Backus

Reputation: 1914

Unfortunately, clang-format treats the << operator as special. What you see is apparently another special case, where two raw strings in a row always get separated onto separate lines. I can't find any way to disable this behavior. I've verified it on both clang-format 6.0.0 and 10.0.0 (using the configurator), so it has been there awhile.

I think it's a bug in clang-format.

Upvotes: 1

Related Questions