As a developer, one of the main challenge when we switch IDE is, we became so powerless as we’re not familiar with the shortcut of the other IDE. So thought of sharing some neat similar functionality shortcut of Xcode and Android Studio, to help one switching to the other easier

Before moving further, just to provide definition of keys as below.

⇧ = Shift ⌃ = Control ⌥ = Option ⌘ = Command

⇡ = Up arrow ⇣ = Down arrow ⇠ = Left arrow ⇢ = Right arrow

⇥ = Tab ↩ = Return ⌫ = Delete

Hide away all other windows (except the editor)

Sometimes especially on the smaller monitor device, we want to maximize our code editor by closing all other feature windows. It would be handy to use shortcut to show and hide them

In Xcode

There’s no single shortcut that close all windows, but there are 3 of them

⌘ 0 : Hide/show the left Panel

: Hide/show the left Panel ⌥ ⌘ 0 : Hide/show the right Panel

: Hide/show the right Panel ⇧ ⌘ Y : Hide/show the bottom Panel

In Android

Use ⇧ ⌘ F12 , and every windows would be hidden away immediately (no animation). Press ⇧ ⌘ F12 to get them back.

Switch to different Windows/Tabs

At times we’re just lazy to use mouse or pad to move point to the windows tab. We could use shortcut to achieve some of them easily.

In Xcode

For switching across windows and tabs

Use ⌘ 1 to ⌘ 9 to switch on the tab of the left windows

to to switch on the tab of the left windows Use ⌥ ⌘ 1 to ⌥ ⌘ 6 to switch on the tab of the right windows

In Android Studio

When a user click on ^ ⇥ (tab) or ⇧ ^ ⇥ (tab), a dialog window showing the complete list of windows could be selected from it. It has

The tools windows on the left

The opened codes file on the right

For the left panel, one could click on 0, 1, 2, 6, 7 … B, D, E… to open the specific windows. For the right panel, just continue clicking on ^ ⇥ or ⇧ ^ ⇥ to move forward or backward to reach the windows to open.

Navigation

For across file search and navigation, you could refer to my other blogs for detail

The summary (limited to those that have shortcut) as below

╔═════════════════════╦═══════════════════╦══════════════════╗

║ Item ║ Xcode ║ Android Studio ║

╠═════════════════════╬═══════════════════╬══════════════════╣

║ Search within file ║ ⌘ F ║ ⌘ F ║

║ Search Across File ║ ⇧ ⌘ F ║ ⇧ ⌘ F ║

║ Search File ║ ⇧ ⌘ O ║ ⇧ ⇧ ║

║ See previous code ║ ^ ⌘ ⇠ ║ ⌘ [ ║

║ See next code ║ ^ ⌘ ⇢ ║ ⌘ ] ║

║ Find definition ║ ^ ⌘ J ║ ⌘ ⇣ ║

╚═════════════════════╩═══════════════════╩══════════════════╝

Code view navigation

The basic cursor movements short cut as below.

╔═════════════════════╦═══════════════════╦══════════════════╗

║ Item ║ Xcode ║ Android Studio ║

╠═════════════════════╬═══════════════════╬══════════════════╣

║ Move right one word ║ ⌥ ⇢ ║ ⌥ ⇢ ║

║ Move left one word ║ ⌥ ⇠ ║ ⌥ ⇠ ║

║ Move to most right ║ ^ ⇢ ║ ^ ⇢ ║

║ Move to most left ║ ^ ⇠ ║ ^ ⇠ ║

║ Move to top ║ ^ ⇡ ║ Fn ⌘ ⇠ ║

║ Move to most left ║ ^ ⇠ ║ Fn ⌘ ⇠ ║

╚═════════════════════╩═══════════════════╩══════════════════╝

Expand and collapse code

Sometimes a function is too long, and we just like to look over it, by collapsing it. There’s shortcut to do so

In Xcode

Use ⌥ ⌘ ⇠ to collapse

to collapse Use ⌥ ⌘ ⇢ to expand

To collapse all, use ⇧ ⌥ ⌘ ⇠ (and ⇧ ⌥ ⌘ ⇢ to expand). This only works for function and class function, as reported in stackoverflow.

In Android Studio

Use ⌘ - to collapse

to collapse Use ⌘ + to expand

To collapse all, use ⇧ ⌘ — (and ⇧ ⌘ + to expand)

Code editing shortcuts

Below are some basic common shortcuts

╔═════════════════════╦═══════════════════╦══════════════════╗

║ Item ║ Xcode ║ Android Studio ║

╠═════════════════════╬═══════════════════╬══════════════════╣

║ Delete a line ║ ^ A K ║ ⌘ ⌫(delete)║

║ Duplicate a line ║ -Not available- ║ ⌘ D ║

║ Comment out ║ ⌘ / ║ ⌘ / ║

║ Move code up ║ ⌥ ⌘ [ ║ ⇧ ⌘ ⇡ ║

║ Move code down ║ ⌥ ⌘ ] ║ ⇧ ⌘ ⇣ ║

╚═════════════════════╩═══════════════════╩══════════════════╝

For Delete a line the ^ A (in Xcode) is to move the cursor to the beginning of the line. Else ^ K would just delete anything after the cursor.

For moving code up and down, in Xcode, it would move beyond the scope.

In Android Studio, the movement is limited to the scope only.

Code formatting shortcuts

There are no common features of formatting in Xcode and Android that perform same formatting. However the below are something somewhat similar.

In Xcode, we could auto indent the code using ^ i . That will apply to the line the cursor is in. If we want to auto-indent all, just use ⌘ A to select all, the apply ^ i to indent all.

In Android Studio, there’s two different formatting.

Optimize and sort the imports using ^ ⌥ O

Reformat the code style using ⌥ ⌘ L . This will remove unnecessary spaces, indent fix etc.

Code execution shortcuts

Compile and run

╔═════════════════════╦═══════════════════╦══════════════════╗

║ Item ║ Xcode ║ Android Studio ║

╠═════════════════════╬═══════════════════╬══════════════════╣

║ Just compile/build ║ ⌘ B ║ ⌘ F9 ║

║ Run without debug ║ -Not available- ║ ^ R ║

║ Run and debug ║ ⌘ R ║ ^ D ║

║ Clean Project ║ ⇧ ⌘ K ║ -Not available- ║

║ Run Unit Test ║ ⌘ U ║ ⇧ ⌥ R ║

╚═════════════════════╩═══════════════════╩══════════════════╝

Debug navigation