I am new to Android Studio and want to know about shortcuts. In Eclipse we use shift-ctrl-O for importing. In Android Studio we use alt-enter. My question about importing override methods and unimplemented methods. Is there a shortcut for these in Android Studio?
20 Answers
Yes, the list of keyboard shortcuts for Android Studio is at https://developer.android.com/studio/intro/keyboard-shortcuts.html.
Here are a few that I know.
Check :File ->Settings ->Keymap -> <Choose Eclipse from Keymaps dropdown> or
Add unimplemented methods: CTRL + I
Override methods: CTRL + O
Format code: CTRL + ALT + L
Show project: ALT + 1
Show logcat: ALT + 6
Hide project - logcat: SHIFT + ESC
Build: CTRL + F9
Build and Run: CTRL + F10
Expand all: CTRL + SHIFT + NumPad +
Collapse all: CTRL + SHIFT + NumPad -
Find and replace: CTRL + R
Find: CTRL + F
In case I'm missing any shortcut that you need you can ask here and for more check implink!! or link!!:)
If you use Android Studio with Mac OS X these are some shortcuts:
- Compile java sources SHF+CMD+F9
- Build the project CMD+F9
- Run the current configuration CTR+R
- Run in debugger CTR+D
- Open project properties CMD++;
- Open Android Studio preferences CMD++,
- Find any command SHF+CMD+A
- Auto-format code OPT+CMD+L
- Delete line CMD+DELETE or CMD+Backspace
- Duplicate line/selection CMD+D
- Copy line CMD+C (with nothing selected)
- Select next occurance(s) CTR+G
Scope based selection
Select next higher scope Option+UP
Select next lower scope Option+DOWN
Navigating the code
- Open class CMD+O
- Open file SHF+CMD+O
- Navigate back to last position CMD+[
- Navigate forward to previous position CMD+]
- Switch to recently used files CRT+TAB
Intention Actions
- If/Switch actions Option+RETURN
Create method CMD+N
or
Loop an array of ints
- Generate Logs usin
logd
,loge
,logi
,logt
,logm
andlogr
- Project quick fix ALT+ENTER
- Show docs for selected API F1
- Jump to source CMD+down-arrow
Most of them I found on this really good article and Android Studio Tips and Tricks
Yes you can go to File -> Settings -> Editor -> Auto Import -> Java and make the following changes:
1.change Insert imports on paste value to All in drop down option.
2.markAdd unambigious imports on the fly option as checked.(For Window or linux user)
On a Mac, do the same thing in Android Studio -> Preferences
3.You can also use Eclipse shortcut key in Android Studio just go to in Android Studio
File -> Settings -> KeyMap -> Keymaps dropdown Option. Select from them
Thankyou
Important Android Studio Shortcuts You Need the Most
Navigation Shortcuts
Go to class : CTRL + N
Go to file : CTRL + SHIFT + N
Navigate open tabs : ALT + Left-Arrow; ALT + Right-Arrow
Lookup recent files : CTRL + E
Go to line : CTRL + G
Navigate to last edit location : CTRL + SHIFT + BACKSPACE
Go to declaration : CTRL + B
Go to implementation : CTRL + ALT + B
Go to source : F4
Go to super Class : CTRL + U
Show Call hierarchy : CTRL + ALT + H
Search in path/project : CTRL + SHIFT + F
Programming Shortcuts
Reformat code : CTRL + ALT + L
Optimize imports : CTRL + ALT + O
Code Completion : CTRL + SPACE
Issue quick fix : ALT + ENTER
Surround code block : CTRL + ALT + T
Rename and refactor : SHIFT + F6
Line Comment or Uncomment : CTRL + /
Block Comment or Uncomment : CTRL + SHIFT + /
Go to previous/next method : ALT + UP/DOWN
Show parameters for method : CTRL + P
Quick documentation lookup : CTRL + Q
General Shortcuts
Delete line : CTRL + Y
Safe Delete : ALT + DELETE
Close Active Tab : CTRL + F4
Build and run : SHIFT + F10
Build : CTRL + F9
All purpose (Meta)Shortcut : CTRL + SHIFT + A
Android Studio is built on IntelliJ IDEA Community Edition, the popular Java IDE by JetBrains. This allows the user to select their own keymap (supporting different IDE shortcuts in your IDE).
You can use "Mac os X, Visual studio, Eclipse, Netbeans etc.. shortcuts in your Android Studio by doing the following:
File
-> Settings
-> Keymap
-> choose "Eclipse
" from dropdown.
OR press Ctrl+Alt+S -> keymap
-> choose "Eclipse
" from dropdown like this.
You can change your keymap to use eclipse shortcuts. You can see here how to change keymap. https://stackoverflow.com/a/25419358
View > Quick Switch Scheme > Keymap > Eclipse
use this option for eclipse keymap or if u want to go with AndroidStudio keymap then follow below link
Click here for Official Android Studio Keymap Refference guide
you may find default keymap referrence in
AndroidStudio --> Help-->Default keymap refrence
These are some of the useful shortcuts for Android studio (Windows)
Double Shift - Search EveryWhere
Ctrl + Shift+A - quick command search
Ctrl +N - Find Class (capable of finding internall classes aswell)
Ctrl +Shift+N - Find File
Alt+F7 - Find Uses (To get the call hierarchy)
Ctrl+B - goto class definition.
Ctrl+LeftClick - goto to symbol(variable, method, class) definition/definition.
Ctrl+Alt+Left - Back
Ctrl+Alt+Right - Right
Shift+f6 - Refactor/Rename
Update
From Android Studio v3.0.1:
In Android Studio, by pressing ALT + INSERT (or ⌘ + N for MacOS), you will have following choices (including your solution!):
- Constructor
- Getter
- Setter
- Getter and Setter
- equals() and hashCode()
- toString()
- Override Methods...
- Implement Methods...
- Delegate Methods...
- Super Method Call (When inside an Override Method)
- Copyright
- App Indexing API Code (Not available inside class extending Fragment.)
Note: Some methods are auto implemented but you can select
Override Methods...
option to implement other unimplemented methods.
Alt+enter is a 'fast solving problems option'. If you try it over class name after writing 'implements XXXX' it will suggest you to autoimplemnt that methods.
The correct shortcut for 'Organice imports' is Ctrl+Alt+O
You can find a really good Android Studio/IntellyJ shortcuts cheatsheet here: IntellyJ shortcut cheatsheet
------Hint-----
Give a try to Live Templates in Android Studio (It's like magic). Just press Ctrl+J
These are for shortcuts specific to android studio.And since it is based on IntelliJ Idea studio,these will work too
answering your specific question,Android Studion is quite logical wrt to shortcuts,for eg for all the situations you asked,try alt-insert
Using Eclipse key mapping inside Android Studio is the better choice. It will easily adapt to existing key structure. But all the new persons are using new shortcut key structures in Android Studio has. So we will learn and follow Android Studio itself contain shortcuts will help easily interact the team mates.
If you use Android Studio in Max OS X mean to follow the below link. It works for me. https://stackoverflow.com/a/30891985/2219406
in androidstudio 3.0(>=) in menu bar go to help-> keymap Reference It will give all the shortcuts .. link
Save all Control + S Command + S
Synchronize Control + Alt + Y Command + Option + Y
Maximize/minimize editor Control + Shift + F12 Control + Command + F12
Add to favorites Alt + Shift + F Option + Shift + F
Inspect current file with current profile Alt + Shift + I Option + Shift + I
Quick switch scheme Control + (backquote) Control +
(backquote)
Open settings dialogue Control + Alt + S Command + , (comma)
Open project structure dialog Control + Alt + Shift + S Command + ; (semicolon)
Switch between tabs and tool window Control + Tab Control + Tab
Navigating and searching within Studio
Search everything (including code and menus) Press Shift twice Press Shift twice
Find Control + F Command + F
Find next F3 Command + G
Find previous Shift + F3 Command + Shift + G
Replace Control + R Command + R
Find action Control + Shift + A Command + Shift + A
Search by symbol name Control + Alt + Shift + N Command + Option + O
Find class Control + N Command + O
Find file (instead of class) Control + Shift + N Command + Shift + O
Find in path Control + Shift + F Command + Shift + F
Open file structure pop-up Control + F12 Command + F12
Navigate between open editor tabs Alt + Right/Left Arrow Control + Right/Left Arrow
Jump to source F4 / Control + Enter F4 / Command + Down Arrow
Open current editor tab in new window Shift + F4 Shift + F4
Recently opened files pop-up Control + E Command + E
Recently edited files pop-up Control + Shift + E Command + Shift + E
Go to last edit location Control + Shift + Backspace Command + Shift + Backspace
Close active editor tab Control + F4 Command + W
Return to editor window from a tool window Esc Esc
Hide active or last active tool window Shift + Esc Shift + Esc
Go to line Control + G Command + L
Open type hierarchy Control + H Control + H
Open method hierarchy Control + Shift + H Command + Shift + H
Open call hierarchy Control + Alt + H Control + Option + H
Writing code
Generate code (getters, setters, constructors, hashCode/equals, toString, new file, new class) Alt + Insert Command + N
Override methods Control + O Control + O
Implement methods Control + I Control + I
Surround with (if...else / try...catch / etc.) Control + Alt + T Command + Option + T
Delete line at caret Control + Y Command + Backspace
Collapse/expand current code block Control + minus/plus Command + minus/plus Collapse/expand all code blocks Control + Shift + minus/plus Command + Shift +
minus/plus
Duplicate current line or selection Control + D Command + D
Basic code completion Control + Space Control + Space
Smart code completion (filters the list of methods and variables by expected type)
Control + Shift + Space Control + Shift + Space
Complete statement Control + Shift + Enter Command + Shift + Enter
Quick documentation lookup Control + Q Control + J
Show parameters for selected method Control + P Command + P
Go to declaration (directly) Control + B or Control + Click Command + B or Command + Click
Go to implementations Control + Alt + B Command + Alt + B
Go to super-method/super-class Control + U Command + U
Open quick definition lookup Control + Shift + I Command + Y
Toggle project tool window visibility Alt + 1 Command + 1
Toggle bookmark F11 F3
Toggle bookmark with mnemonic Control + F11 Option + F3
Comment/uncomment with line comment Control + / Command + /
Comment/uncomment with block comment Control + Shift + / Command + Shift + /
Select successively increasing code blocks Control + W Option + Up
Decrease current selection to previous state Control + Shift + W Option + Down
Move to code block start Control + [ Option + Command + [
Move to code block end Control + ] Option + Command + ]
Select to the code block start Control + Shift + [ Option + Command + Shift + [
Select to the code block end Control + Shift + ] Option + Command + Shift + ]
Delete to end of word Control + Delete Option + Delete
Delete to start of word Control + Backspace Option + Backspace
Optimize imports Control + Alt + O Control + Option + O
Project quick fix (show intention actions and quick fixes) Alt + Enter Option + Enter
Reformat code Control + Alt + L Command + Option + L
Auto-indent lines Control + Alt + I Control + Option + I
Indent/unindent lines Tab/Shift + Tab Tab/Shift + Tab
Smart line join Control + Shift + J Control + Shift + J
Smart line split Control + Enter Command + Enter
Start new line Shift + Enter Shift + Enter
Next/previous highlighted error F2 / Shift + F2 F2 / Shift + F2
Build and run
Build Control + F9 Command + F9
Build and run Shift + F10 Control + R
Apply changes (with Instant Run) Control + F10 Control + Command + R
Debugging
Debug Shift + F9 Control + D
Step over F8 F8
Step into F7 F7
Smart step into Shift + F7 Shift + F7
Step out Shift + F8 Shift + F8
Run to cursor Alt + F9 Option + F9
Evaluate expression Alt + F8 Option + F8
Resume program F9 Command + Option + R
Toggle breakpoint Control + F8 Command + F8
View breakpoints Control + Shift + F8 Command + Shift + F8
Refactoring
Copy F5 F5
Move F6 F6
Safe delete Alt + Delete Command + Delete
Rename Shift + F6 Shift + F6
Change signature Control + F6 Command + F6
Inline Control + Alt + N Command + Option + N
Extract method Control + Alt + M Command + Option + M
Extract variable Control + Alt + V Command + Option + V
Extract field Control + Alt + F Command + Option + F
Extract constant Control + Alt + C Command + Option + C
Extract parameter Control + Alt + P Command + Option + P
Version control / local history
Commit project to VCS Control + K Command + K
Update project from VCS Control + T Command + T
View recent changes Alt + Shift + C Option + Shift + C
Open VCS popup Alt + ` (backquote) Control + V
Search
All
- Search Everywhere
Double ShiftClasses
- Find class:
Mac: ⌘ Command + O
Windows/Linux: Ctrl + NFiles
- Find file:
Mac: ⌘ Command + Shift + O
Windows/Linux: Ctrl + Shift + NSymbols
- Search by symbol name:
Mac: ⌘ Command + ⌥ Option + O
Windows/Linux: Ctrl + Alt + Shift + NAction
- Find action:
Mac: ⌘ Command + Shift + A
Windows/Linux: Ctrl + Shift + A