Friday, January 23, 2015

Code formatting shortcut key in Android studio, Eclipse , Netbeans and XCode

Android studio:

CTRL + ALT + L (Win/ Linux)
OPTION + CMD + L (Mac)
Reference : Key Commands and here is full commands for Windows/ Linux users and for Mac users

Update for Ubuntu As Rohit faced the problem in Ubuntu to format code shortcut, because the CTRL + ALT + L key is used to lock the screen in Ubuntu.
I found that Ubuntu which handle the key event first. So try to change the CTRL+ALT+L action in Ubuntu just to be sure.
Steps are :-
Go to System Tools -> System Settings -> Keyboard -> Shortcuts Tab -> System -> Lock Screen
Select the row New Accelerator... will be visible then press any Special key with Alpha key (like Shift + L). You changed the key shortcuts.
Now check format key in Studio.

Update came from Henry Chuang, and also in another answer given by user2340612.
You can also use eclipse sortcuts. Windows and Linux, go to File > Settings > Keymap , Mac OS X, go to > Preferences > Keymap and choose eclipse from the dropdown menu.


I use NetBeans 7.1. Pressing Alt+Shift+F indents your selection. If nothing's selected, it indents the whole file.
In newer versions of NetBeans, you can even format multiple files/folders at a time! In the Projectswindow/sidebar, if you select one or more folders or files and press Alt+Shift+F. NetBeans asks"Recursively format selected files and folders?" and pressing OK will recursively format all the selected files/folders.
On Mac OS X, shortcut is Ctrl+Shift+F. (note: it's Ctrl and not )


Ctrl+Shift+F to invoke the Auto Formatter
Ctrl+I to indent the selected part (or all) of you code.

Use Cmd+A first if you wish to format all text.

The keyboard shortcut is Ctrl+I


  1. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Angular training in chennai

    1. Thanks ROSHINI RS for reading this tutorial.



Copyright @ 2014 Tech Tutorial .