I prefer Allman-style braces, for example:
if (foo)
{
// magical prancing unicorn stuff
}
rather than:
if (foo) {
// unmagical boring pony things
}
The Java formatter in Eclipse handles this pretty well, except for empty code blocks, which it formats like this:
SomeDefaultCtor()
{}
I'd like to use this special format for empty blocks instead:
SomeDefaultCtor() {}
Is there any way to tell Eclipse to leave braces on the same line when the braces surround an empty code block? So far, I can't see one:
As far as I can tell this is not (yet) possible in eclipse; you can specify when new lines should be inserted or not but the configuration on the braces takes priority. If you feel strongly about this and do not despise IDE annotations for this you could use:
@formatter:off
SomeDefaultCtor() {}
@formatter:on
These must be enabled in the eclipse formatter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With