Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java How to beautify the java code inside Eclipse IDE

I am using Eclipse Helios Version as an IDE and developing code using Java.

The good thing for me is that the code works well, but the bad thing is that the code doesn't look good ( I mean spaces and brackets used in control structures used in if-else statments as well as for and while loops scattered here and there )

I have used Ctrl + Shift + F , as well as an online tool (http://www.prettyprinter.de/) for formatting , and with this it looks more worse.

As a lot of developers are out here, how do you arrange your code properly and how you make it look good.

Please tell me , I am worried as some senior person might review the code .

like image 633
Revathi Avatar asked Nov 08 '11 06:11

Revathi


People also ask

How can I get beautify code in Eclipse?

Go to Source | Format Document or press Ctrl+Shift+F.

How do I indent my Java code in Eclipse?

You can use Ctrl + A to select the entire file, then use this shortcut to quickly fix all the indentation. You can also change how Eclipse handles indentation by going to Window > Preferences, then in the left panel, navigate to Java > Code Style > Formatter > Edit... > Indentation.


1 Answers

Try to change Window->Preferences->Java->Code Formatter->LineSplittin-> Maximum Line length up to 120 or 140 symbols.

like image 67
xander_blr Avatar answered Oct 19 '22 23:10

xander_blr