I've tried clang-format. It doesn't do what I need, it is not very flexible and authors are refusing to create additional formatting options. But the main problem for me is that it cannot do incremental formatting. I cannot say: do just indentation and leave everything else as it is. It force to do my pet project in some corporate style, preventing even possibility of experiments with style.
I've tried astyle. It doesn't support complicated things like clang-format do, but it does a lot of options, and most of all, it does support incremental formatting. The problem is it fails to produce correct results on longer files. Looks like some buffer processing problem, because about every 300th line got weird. Sometimes even with syntax errors.
I've tried uncrustify. So far it is the best choice, but it still has some drawbacks. The configuration is really cryptic and I can't say that it is documented enough. I was able to configure it to do indentation only. And... it looks like it cannot properly indent nested classes.
Yes, I know, all of them are open source projects and can fix them or change them as I like. But first, that's not what I want to do right now, and second, I don't want to end up supporting my own private branch and spend time incorporating my changes on every version update or stick to some old and obsolete modified version.
Any other options?





Well, you just listed the two I'd suggest.
clang-formatisn't going to force you to use a corporate style. You can select one as the default for anything unspecified, but if you're like me and want everything your way, you can go through and define everything.I'm guessing that LLVM's unwillingness to create additional
-style=designations is what you're referring to, but think about it - that's perfectly reasonable. Imagine if 200 people requested that their Pet Style were adopted! It would make a hash of the whole thing.If you want to set your own style to reuse over and over, you create a
.clang-formatfile for your project and reuse it. That's just how you're supposed to use it.(Full docs are here.)
You can get a valid default clang-format configuration file via...
And then change everything to what you want. Stick the
.clang-formatfile in your project directory and use it for runningclang-format. Easy breezy cider squeezy.On that note, it really isn't a practical to leave anything in coding style to "do-whatever-I-don't-care". Experiment, settle on a style, and stick with it.