[cfe-dev] clang-format: how to avoid aligned indentation on wrapping

Matt Liberty matt.liberty at gmail.com
Fri Jan 23 22:33:39 PST 2015


Hi

I like to keep the { on the same line when wrapping isn't required, eg

for (a; b; c) {
    d;
}

but I don't like it on the same line when wrapped:

for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
     cccccccccccccccccccccccccccccc) {
    dddddddddddddddddddddddddddddd;
}

I find it hard to distinguish the scope quickly as the c's and d's nearly
align.  I find:

for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
     cccccccccccccccccccccccccccccc)
{
    dddddddddddddddddddddddddddddd;
}

preferable in this case.  I can't find a why to selectively have the {
positioned.  BreakBeforeBraces in Allman style doesn't support the single
line case and the others don't support the later case.

Is there a way to make work?  If not I'm glad to work on coding a solution
but would appreciate some pointers.

Thanks,
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150123/96d321b9/attachment.html>


More information about the cfe-dev mailing list