11

I'm trying to find a way to align all the variable names and classes names in android studio, is there a way to do this automatically?

For example I want android studio to do this automatically:

    private void    someFunction()
{
    int             someVariable;
    TextView        anotherVariable;

}

For now I'm doing it manually by it would be easier if it could do it automatically. thanks

lguenier
  • 187
  • 1
  • 10

2 Answers2

20

In Android Studio 1.3 you can enable this here:

Project Settings | Code Style | Java | Wrapping and Braces | Group declarations | Align fields in columns

enter image description here

To reformat your code manually, press Ctrl + Alt + L (or using the menu Code | Reformat code...).

More information about reformating source code can be found on the IntelliJ Web Help

Andrea Thacker
  • 3,440
  • 1
  • 25
  • 37
Darek Kay
  • 15,827
  • 7
  • 64
  • 61
0

Code > Auto-indent Lines (Ctrl-Alt-I)

m0skit0
  • 25,268
  • 11
  • 79
  • 127
  • well it isn't the auto indent of lines I'm talking about but rather hte indetation of the names of variables that I want. – lguenier Sep 30 '14 at 08:41
  • Oh ok, but just FYI this is not standard Java indentation (same goes for brace on new line) http://www.oracle.com/technetwork/java/codeconvtoc-136057.html – m0skit0 Sep 30 '14 at 08:47
  • Yes I know, this is the way of doing for C norm at my school, so I guess I'll just have to abandon that habit (which is BTW more readable than the other one... :( ) Thanks for the link! – lguenier Sep 30 '14 at 09:03
  • You're welcome. I agree that brace at a line by itself is more readable and more consistent (the closing brace is always at a line by itself...). – m0skit0 Sep 30 '14 at 09:07