From the course: IntelliJ IDEA Community Edition Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Reformat code and optimize imports

Reformat code and optimize imports

From the course: IntelliJ IDEA Community Edition Essential Training

Start my 1-month free trial

Reformat code and optimize imports

- [Instructor] When you're coding in a hurry, you sometimes don't pay attention to things like indentation or line feeds to make your code readable. IntelliJ IDEA can clean all that up for you with a tool called Reformat Code. Here's a couple of ways you can use it. I'll start with this class called Person. And I'm going to select everything. And I did that by pressing Command A on Mac or Control A on Windows. Then I'll press Shift and Tab a few times to indent everything over to the left. Now, I want to add indentation back in. I'll click anywhere in the code editor. Then I'll go to the menu and choose Code, Reformat Code. And everything is fixed instantly. Now, there's another way of using that reformat code tool. I'm going to press Command Z for undo on Mac or Control Z on Windows. And now I'm back in that same state. And now, I'll come back over to my project window. And with Person.java selected, I'll click on this…

Contents