Saturday 15 July 2023

Important Keyboard shortcuts in Android Studio

Shortcuts are increase programming speed. It's increase the well style coding format and other features.

Keyboard shortcuts are a useful way of quickly navigating around Android Studio and performing common actions. In many cases, using keyboard shortcuts is faster than using the GUI.


You can use keyboard shortcuts to open tool windows. Table 1 lists the shortcuts for the most common windows.

Table 1. Keyboard shortcuts for common tool windows

Tool windowWindows and LinuxmacOS
ProjectAlt+1Command+1
Version ControlAlt+9Command+9
RunShift+F10Control+R
DebugShift+F9Control+D
LogcatAlt+6Command+6
Return to EditorEscEsc
Hide All Tool WindowsControl+Shift+F12Command+Shift+F12

Android Studio has three types of code completion, which you can access using keyboard shortcuts, as shown in the following table.

Table 2. Keyboard shortcuts for code completion

TypeDescriptionWindows and LinuxmacOS
Basic CompletionDisplays basic suggestions for variables, types, methods, expressions, and so on. If you call basic completion twice in a row, you see more results, including private members and non-imported static members.Control+SpaceControl+Space
Smart CompletionDisplays relevant options based on the context. Smart completion takes into account the expected type and data flows. If you call Smart Completion twice in a row, you see more results, including chains.Control+Shift+SpaceControl+Shift+Space
Statement CompletionCompletes the current statement, adding missing parentheses, brackets, braces, formatting, and so on.Control+Shift+EnterCommand+Shift+Enter

To perform quick fixes and show intention actions, press Alt+Enter.

Use the following tips to help navigate around Android Studio:

  • Switch between your recently accessed files using the Recent Files action. To bring up the Recent Files action, press Control+E (Command+E on macOS). By default, the last accessed file is selected. You can also access any tool window through the left column in this action.
  • View the structure of the current file using the File Structure action. To bring up the File Structure action, press Control+F12 (Command+F12 on macOS). Using this action, you can quickly navigate to any part of your current file.
  • Search for and navigate to a specific class in your project using the Navigate to Class action. To bring up the Navigate to Class action, press Control+N (Command+O on macOS).

    Navigate to Class supports sophisticated expressions, including camel humps (which lets you search by the capitalized letters in an element's camel-cased name), paths, line navigate to (which lets you navigate to a specific line within the file), and middle name matching (which lets you search for a part of the class name). If you call it twice in a row, it shows you the results out of the project classes.

  • Navigate to a file or folder using the Navigate to File action. To bring up the Navigate to File, press Control+Shift+N (Command+Shift+O on macOS). To search for folders rather than files, add a / at the end of your expression.

  • Navigate to a method or field by name using the Navigate to Symbol action. To bring up the Navigate to Symbol action, press Control+Alt+Shift+N (Command+Option+O on macOS).

  • To find all the pieces of code referencing the class, method, field, parameter, or statement at the current cursor position, press Alt+F7 (Option+F7 on macOS).

Android Studio includes keyboard shortcuts for many common actions. Table 3 shows the default keyboard shortcuts by operating system.

Note: In addition to the default keymaps in table 3, you can select from a number of preset keymaps or create a custom keymap. For more about customizing your keyboard shortcuts, see the Configure custom keymaps section.

Table 3. Default keyboard shortcuts for Windows or Linux and macOS operating systems

DescriptionWindows and LinuxmacOS
General actions
Save allControl+SCommand+S
SynchronizeControl+Alt+YCommand+Option+Y
Maximize/minimize editorControl+Shift+F12Control+Command+F12
Add to favoritesAlt+Shift+FOption+Shift+F
Inspect current file with current profileAlt+Shift+IOption+Shift+I
Quick switch schemeControl+` (backtick)Control+` (backtick)
Open settings dialogControl+Alt+SCommand+, (comma)
Open project structure dialogControl+Alt+Shift+SCommand+; (semicolon)
Switch between tabs and tool windowControl+TabControl+Tab
Navigate and search within Android Studio
Search everything (including code and menus)Press Shift twicePress Shift twice
FindControl+FCommand+F
Find nextF3Command+G
Find previousShift+F3Command+Shift+G
ReplaceControl+RCommand+R
Find actionControl+Shift+ACommand+Shift+A
Search by symbol nameControl+Alt+Shift+NCommand+Option+O
Find classControl+NCommand+O
Find file (instead of class)Control+Shift+NCommand+Shift+O
Find in pathControl+Shift+FCommand+Shift+F
Open file structure dialogControl+F12Command+F12
Navigate between open editor tabsAlt+Right Arrow or Left ArrowControl+Right Arrow or Control+Left Arrow
Jump to sourceF4 or Control+EnterF4 or Command+Down Arrow
Open current editor tab in new windowShift+F4Shift+F4
Recently opened files dialogControl+ECommand+E
Recently edited files dialogControl+Shift+ECommand+Shift+E
Go to last edit locationControl+Shift+BackspaceCommand+Shift+Delete
Close active editor tabControl+F4Command+W
Return to editor window from a tool windowEscEsc
Hide active or last active tool windowShift+EscShift+Esc
Go to lineControl+GCommand+L
Open type hierarchyControl+HControl+H
Open method hierarchyControl+Shift+HCommand+Shift+H
Open call hierarchyControl+Alt+HControl+Option+H
View layouts
Zoom in/outControl+plus or Control+minusCommand+plus or Command+minus
Fit to screenControl+0Command+0
Actual sizeControl+Shift+1Command+Shift+1
Design tools: Layout Editor
Toggle between Design and Blueprint modesBB
Toggle between Portrait and Landscape modesOO
Toggle devicesDD
Force refreshRR
Toggle render errors panelEE
Delete constraintsDelete or Control+clickDelete or Command+click
Zoom inControl+plusCommand+plus
Zoom outControl+minusCommand+minus
Zoom to fitControl+0Command+0
PanHold Space+click and dragHold Space+click and drag
Go to XMLControl+BCommand+B
Select all componentsControl+ACommand+A
Select multiple componentsShift+click or Control+clickShift+click or Command+click
Design tools: Navigation Editor
Zoom inControl+plusCommand+plus
Zoom outControl+minusCommand+minus
Zoom to fitControl+0Command+0
PanHold Space+click and dragHold Space+click and drag
Go to XMLControl+BCommand+B
Toggle render errors panelEE
Group into nested graphControl+GCommand+G
Cycle through destinationsTab or Shift+TabTab or Shift+Tab
Select all destinationsControl+ACommand+A
Select multiple destinationsShift+click or Control+clickShift+click or Command+click
Write code
Generate code (getters, setters, constructors, hashCode/equalstoString, new file, new class)Alt+InsertCommand+N
Override methodsControl+OControl+O
Implement methodsControl+IControl+I
Surround with (if...elsetry...catch, etc.)Control+Alt+TCommand+Option+T
Delete line at caretControl+YCommand+Delete
Collapse/expand current code blockControl+minus or Control+plusCommand+minus or Command+plus
Collapse/expand all code blocksControl+Shift+minus or Control+Shift+plusCommand+Shift+minus or Command+Shift+plus
Duplicate current line or selectionControl+DCommand+D
Basic code completionControl+SpaceControl+Space
Smart code completion (filters the list of methods and variables by expected type)Control+Shift+SpaceControl+Shift+Space
Complete statementControl+Shift+EnterCommand+Shift+Enter
Quick documentation lookupControl+QControl+J
Show parameters for selected methodControl+PCommand+P
Go to declaration (directly)Control+B or Control+clickCommand+B or Command+click
Go to implementationsControl+Alt+BCommand+Option+B
Go to supermethod/superclassControl+UCommand+U
Open quick definition lookupControl+Shift+ICommand+Y
Toggle project tool window visibilityAlt+1Command+1
Toggle bookmarkF11F3
Toggle bookmark with mnemonicControl+F11Option+F3
Comment/uncomment with line commentControl+/Command+/
Comment/uncomment with block commentControl+Shift+/Command+Shift+/
Select successively increasing code blocksControl+WOption+Up
Decrease current selection to previous stateControl+Shift+WOption+Down
Move to code block startControl+[Option+Command+[
Move to code block endControl+]Option+Command+]
Select to the code block startControl+Shift+[Option+Command+Shift+[
Select to the code block endControl+Shift+]Option+Command+Shift+]
Delete to end of wordControl+DeleteOption+Delete
Delete to start of wordControl+BackspaceOption+Delete
Optimize importsControl+Alt+OControl+Option+O
Project quick fix (show intention actions and quick fixes)Alt+EnterOption+Enter
Reformat codeControl+Alt+LCommand+Option+L
Auto-indent linesControl+Alt+IControl+Option+I
Indent/unindent linesTab or Shift+TabTab or Shift+Tab
Smart line joinControl+Shift+JControl+Shift+J
Smart line splitControl+EnterCommand+Enter
Start new lineShift+EnterShift+Enter
Next/previous highlighted errorF2 or Shift+F2F2 or Shift+F2
Build and run
BuildControl+F9Command+F9
Build and runShift+F10Control+R
Apply changes and restart activityControl+F10Control+Command+R
Apply code changesControl+Alt+F10Control+Command+Shift+R
Debug
DebugShift+F9Control+D
Step overF8F8
Step intoF7F7
Smart step intoShift+F7Shift+F7
Step outShift+F8Shift+F8
Run to cursorAlt+F9Option+F9
Evaluate expressionAlt+F8Option+F8
Resume programF9Command+Option+R
Toggle breakpointControl+F8Command+F8
View breakpointsControl+Shift+F8Command+Shift+F8
Refactor
CopyF5F5
MoveF6F6
Safe deleteAlt+DeleteCommand+Delete
RenameShift+F6Shift+F6
Change signatureControl+F6Command+F6
InlineControl+Alt+NCommand+Option+N
Extract methodControl+Alt+MCommand+Option+M
Extract variableControl+Alt+VCommand+Option+V
Extract fieldControl+Alt+FCommand+Option+F
Extract constantControl+Alt+CCommand+Option+C
Extract parameterControl+Alt+PCommand+Option+P
Version control/local history
Commit project to VCSControl+KCommand+K
Update project from VCSControl+TCommand+T
View recent changesAlt+Shift+COption+Shift+C
Open VCS dialogAlt+` (backtick)Control+V

The keymap settings in Android Studio let you choose from a list of preset options or create a custom keymap.

To open the keymap settings, choose File > Settings (on macOS, Android Studio > Preferences) and navigate to the Keymap pane.

Figure 1. The Android Studio keymap settings window on macOS.

  1. Keymaps menu: Select the desired keymap from this menu to switch between preset keymaps.
  2. Actions list: Right-click an action to modify it. You can add additional keyboard shortcuts for the action, add mouse shortcuts to associate an action with a mouse click, or remove current shortcuts. If you are using a preset keymap, modifying an action’s shortcuts automatically creates a copy of the keymap and adds your modifications to the copy.
  3. Copy button: Select a keymap from the menu to use as a starting point, and click Copy to create a new custom keymap. You can then modify the keymap name and shortcuts.
  4. Reset button: Select a keymap from the menu and click Reset to revert it to its original configuration.
  5. Search box: Type here to search for a keyboard shortcut by the action name.
  6. Search by Shortcut: Click this button and type a shortcut to search for actions by their assigned shortcut.
















No comments:

Post a Comment