How do I align/format code in Android Studio?

Daksharma picture Daksharma · Jan 29, 2015 · Viewed 64.7k times · Source

Is there a way/shortcut/built-in feature that can align code for operands, like '=' signs?

For example, there is a XAlign for Xcode (https://github.com/qfish/XAlign), allowing the user to select code that needs to be aligned and use a shortcut to align it automatically.

There is a Fields Group feature in Android Studio which can "Align in columns", but it does not work for code that is already written.

Answer

Jorgesys picture Jorgesys · Dec 16, 2015

Indent code in Android Studio:


Windows

Ctrl + Alt + L


Mac:

Option + Command + L