R – An autoformat tool to automatically insert braces around single-line clauses

code formattingeclipse

So assuming that in our work environment we've decided that the One True Faith forbids this:

if (something) 
    doSomething();

And instead we want:

if (something) {
    doSomething();
}

Is there a tool that will do that automagically? Awesomest would be to have eclipse just do it, but since we're really just recovering from one ex-employee that thought he was too pretty for coding conventions, a less-friendly tool that would do it right just once would suffice.

Best Answer

I think you can set this in Eclipse's formatting rules and run the built-in formatter.. e.g. the "Use blocks" option:

Code Style Tab

Of course, you need the rest of the formatting options to be set how you want them, since I don't think you can selectively apply only a single rule/option..

Related Topic