Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indenting Java source files using Eclipse

I'm using an UML tool that generates Java classes from the UML class diagram. Unfortunately the code inside is not indented.

How to solve this? How can I indent a file using Eclipse?

like image 778
Heisenbug Avatar asked Aug 17 '11 15:08

Heisenbug


1 Answers

How to indent a Java source file in Eclipse:

  1. Open the file in Eclipse's text editor.
  2. Ctrl+A to select all text.
  3. Ctrl+I to indent the text (or right click > Source > Indent).
  4. Ctrl+S to save the file.

Done.

(If you also want to correct the spacing, then use Ctrl+Shift+F or right click > Source > Format. This can be applied to a single file, or a group of files using the Project Explorer pane.)

like image 65
Nayuki Avatar answered Oct 20 '22 00:10

Nayuki