转载请注明本文出自Cym的博客(http://blog.csdn.net/cym492224103),谢谢支持! About KeymapsAndroid Studio provides different keymaps (the mapping between shortcut keys and an action). You can see which keymap you are using in Settings->Keymap. It wouldn’t be practical to list the shortcuts for every keymap so the following will be used: - Windows: Default
- Linux: Default
- OSX: Mac OSX 10.5+
Refactor ThisThis is a shortcut to contextually show all the available refactorings for the current selection. This list is keyboard searchable and you can use the number on the left for a quicker access Shortcut (Menu): - Mac: Ctrl+T
- Windows/Linux: Ctrl+Alt+Shift+T
Navigate to parentIf you are in a method that is overriding a parent class (e.g. Activity#onCreate()), this will navigate to the parent implementation. If you are on the class name, it will navigate to the parent class. Shortcut : - Mac: Cmd+U
- Windows/Linux: Ctrl+U
Recently Changed FilesThis is a variation of the “Recents” popup that lists files that were recently modified locally. It is sorted in order of modification (most recently edited on top). A nice bonus is that you can type to filter the list. Shortcut (Menu): - Mac: Cmd+Shift+E
- Windows/Linux: Ctrl+Shift+E
Jump to Last Tool WindowSometimes, you return to the editor from a panel but find yourself having to go back to this panel. e.g. browsing find usages. With this, you can go back to a panel without your mouse. Shortcut: F12 (might interfere with the OS’s default keybindings) Related FileIt helps you navigate between your layout and your activity/fragment with ease. There is also a shortcut in the gutter next to the class name and one at the top of the layout file. Shortcut (Menu): - Mac: Ctrl+Cmd+Up
- Windows/Linux: Ctrl+Alt+Home
Extract VariableThis is a shortcut to extract a variable without going through the refactoring menu. This is very useful when you are generating code on the fly as you can avoid typing the variable declaration and go straight to the value. The IDE will then generate the declaration and it will come up with some suggestions on how to name the variable. Additional tip: - If you want to change the declaration type to something more generic (e.g. List instead of ArrayList), you can press Shift+Tab and it will give you a list of valid types.
Shortcut (Menu): - Mac: Cmd+Alt+V
- Windows/Linux: Ctrl+Alt+V
Extract ParameterThis is a shortcut to extract a parameter without going through the refactoring menu. This thing is useful when you realize that a method could be generified by extracting one part as a parameter. The way it works is that it will take the current value, make it a parameter and copy the old value as the parameter for each caller. Additional tip: - You can also keep the original method and have it delegate to the new one by ticking the “delegate” box.
Shortcut (Menu): - Mac: Cmd+Alt+P
- Windows/Linux: Ctrl+Alt+P
Extract MethodFollowing in my streak of extract refactoring, here is the one to extract a code block in a new method. This thing is extremely useful. Whenever you encounter a method that is starting to become a bit complex, you can use this to safely extract a portion in another method. I say safely because the IDE won’t make a silly copy-paste mistake like we might do. Additional tip: - Once you are in the extractin dialog, you can change the visibility of the method and the parameter names.
Shortcut (Menu): - Mac: Cmd+Alt+M
- Windows/Linux: Ctrl+Alt+M
InlineSo you have gone a bit crazy with extraction and now you have too much stuff? You can do the reverse operation, which is called “inline”. This will work with methods, fields, parameters and variables. Shortcut: - Mac: Cmd+Alt+N
- Windows/Linux: Ctrl+Alt+M
RenameWith this, you can rename a variable, field, method, class and event package. This will, of course, make sure that the renaming makes sense in the context of your app, it won’t simply do a find and replace in all files! Additional Tip: - If you can’t remember this shortcut, you can always invoke the quick fix shortcut and it will always include the rename refactoring.
Shortcut: Shift+F6 Pull Up / Push DownWhen we talk about pulling something up, we mean that we will take something in the current class (usually a method or a field) and send it to the parent class or interface. If the parent is a class, the content will be moved. If the parent is an interface, it will declare the method as part of the interface, keep the method in your class and add the @override annotation. When we talk about pushing members down, that is exactly the opposite operation, we are sending content from the parent class/interface in the child class. Shortcut: - Mac: Ctrl+T and choose pull members up / push members down
- Windows/Linux: Ctrl+Alt+Shift+T and choose pull members up / push members down
- 本文出自Cym的博客(http://blog.csdn.net/cym492224103)
|