Learning---shortcut keys for Android Studio

Source: Internet
Author: User

Shortcut key Learning TIPS:

1. Exception code block or custom code block structure ctrl+alt+t or File | Settings | File and Code Templates

When you want to catch exceptions thrown by some code fragment, select it in the editor, press Ctrl+alt+t (code | Surround with) and choose Try/catch. The catch blocks for all the exceptions thrown inside the block would be generated automatically.
You can customize the bodies of the generated catch blocks on the Code tab of File | Settings | File and Code Templates.
Use other items in the list to surround with other constructs

To catch some of the exceptions thrown by blocks of code, select Ctrl+alt+t or right-click (code | Surround with) and choose Try/catch

There are many custom blocks, such as if ... such as

2. Code completion and press ctrl+shift+ space:

The Smarttype code completion is used after the new keyword, to instantiate an object of the expected type. For example, type

when you're talking about a new object, use the shortcut key ctrl+shift+ Spaces:

3. Implementing abstract Methods Ctrl+alt+b

To navigate to the implementation (s) of a abstract method, position the caret at it usage or its name in the declaration     and press Ctrl+alt+b.

4. Extract the variable to refactor, in fact, is a very long code, reduced to a few lines, code good-looking, and the parameters of independent, re-apply a variable, so error is easy to find which problem ctrl+alt+v

The Extract Variable refactoring helps you simplify complicated statements in your code. For example, with the code fragment below, you can select a expression in the code:

and press ctrl+alt+v (Refactor | Extract | Variable ...). This would result in the following:

5. Note the same as the CTRL + Slash in ADT means://; CTRL + Shift + Slash stands for/*...*/

  

You can comment or uncomment lines and blocks of code using CTRL + Slash and ctrl+shift+ slash.
Ctrl + Slash comments or uncomments the current line or selected block with a single line comments (//...).
Ctrl+shift+ Slash encloses the selected block in a block comment (/*...*/).
To uncomment a commented block press ctrl+shift+ slash anywhere inside it.

6.

Ctrl+d in the editor duplicates the selected block or the "The current line" is selected.

7. Tab key

Use the Tab key to move between the template fields. See File | Settings |     Live Templates for more details.

8. Hint variable name CTRL + Space

The Codecompletion feature can suggest a name for a variable when you declare it. For example, start typing

   Private FileOutputStream

and press CTRL + SPACE.

9. See what Ctrl+p the method's parameter type is

If the cursor is between the parentheses of a method call, pressing ctrl+p brings up a list of valid parameters.

10. Code fallback is the operation History Bar Ctrl + Shift + BACKSPACE key

Ctrl+shift+backspace (Navigate | Last Edit location) brings the last place where you made changes in the code.

Pressing ctrl+shift+backspace A few times moves you deeper to your changes history.

11. Make the variable stand out CTRL+SHIFT+F7

Use Ctrl+shift+f7 (Edit | Find | Highlight Usages in File) to quickly Highlight Usages of some variable in the current file.
Use F3 and SHIFT+F3 keys to navigate through highlighted usages.
Press ESC to remove highlighting.

12. Formatting Codes Code | Reformat Code

Use Code | Reformat code to reformat code according to your Code style preferences (File | Settings | Code Style).

can also use Code | Optimize imports to automatically Optimize imports (remove unused imports, etc). To access the corresponding settings, use File | Settings | Code Style |     Imports.

13. Rollback Historical Code Local History | Show history

To see your local history of changes in a file, invoke local History | Show History from the context menu. You can navigate through different file versions, see the differences and roll back to any previous version.

Use the same context menu item to see the history of changes on a directory. You'll never lose any code with this feature!

14. View the declaration of the method alt+q

Press Alt+q (View | Context Info) to see the declaration of the current method without the need to scroll to it.

15. Open the recently accessed file ctrl+e (View | Recent Files)

Ctrl+e (View | Recent files) brings a popup list of the recently visited Files.     Choose the desired file and press Enter to open it.

16. Fast jumping between error syntax

Use f2/shift+f2 the keys to the jumpbetween highlighted syntax errors.

Use ctrl+alt+ up ARROW/ctrl+alt+ down arrow shortcuts to jump between compiler error messages or search operation results.

To-Skip warnings right-click on the validation side Bar/marker bar and choose Go-to-high-priority problems only.

17. Quickly knock out variable name ctrl+j

Use the ctrl+j to complete any valid Live Template abbreviation if you don ' t remember it. For example, the type it and press Ctrl+j to see what happens.

18. Adding separators between methods

To show separator lines between methods in the editor, open the editor settings and select the Show method separators Chec K box in the Appearance page.

19. Fast movement between two methods

Use ALT + UP ARROW and ALT + DOWN ARROW keys to quickly move between methods in the editor.

20. Remove unnecessary spaces ctrl+shift+j

Ctrl+shift+j shortcut joins the lines into one and removes unnecessary space to match your code style.

21. Building a copy of a class

Use Refactor | Copy to create a class which is a copy of the selected class. This can is useful, for example, when you need to create a class which have much in common with some existing class and it ' s not feasible to put the shared functionality in a common superclass.

22. Cut and insert a piece of code

Use the ctrl+shift+v shortcut to choose and Insert recent clipboard contents into the text.

23. View the hierarchical hierarchy of a class ctrl+h

To see the inheritance hierarchy for a selected class, press ctrl+h (Navigate | Type Hierarchy).     You can also invoke the hierarchy view right from the editor to see the hierarchy for the currently edited class.

24. Right mouse button set breakpoint

Right-clicking on a breakpoint marker (on the bar to the left from the text) invokes the Speedmenu where can quickly E Nable/disable the breakpoint or adjust its properties.

25. Evaluate the value of an expression when debugging

To easily evaluate the value of any expression while debugging the program, select the IT text in the editor Ctrl+w a few times to efficiently perform this operation) and press ALT+F8.

26. View the definition description ctrl+q

The shortcuts such as ctrl+q (View | Quick documentation), ctrl+p (View | Parameter Info), ctrl+b (Navigate |     Declaration) and others can is used not only in the editor but the code completion popup list as well.

27. Change the inner class

When you invoke the Move refactoring (F6) on a inner class that's declared static, you were provided with an     option to either make it a top-level class, or move it to another class.

28. Open any one of the variables or methods Ctrl+alt+shift+n

To open any particular method or field in the editor quickly, press ctrl+alt+shift+n (Navigate | Symbol) and start typing its name.

Choose symbol from the Drop-down list that appears.

29. Quick review of recently changed items

Use Alt+shift+c to quickly review your recent changes to the project.

30. Code Quick Add Ctrl + Spaces

Use Basic completion (CTRL + Space) within HTML, CSS and other files, for completing image file names.

31. Lamp identification prompt creates the variable automatically so that you do not leave the current edit position

You can start referring to a Ant property or target even if it's not defined yet. An intention action feature would suggest you-automatically create the necessary tag, without the need for your leave Your current editing location.

32. Padded curly Braces {} ctrl+shift+enter

Use ctrl+shift+enter to complete a current statement such as if, do-while, Try-catch, return (or a Met     Hod call) into a syntactically correct construct (e.g. add curly braces).

33. Debug Run

By pressing ALT+SHIFT+F10 your can access the Run/debug dropdown on the main toolbar, without the need to use your MOUS E.

34. Renaming

It is the possible to rename CSS selectors directly from HTML. Position the caret at the selector to be renamed and press Shift+f6 (Refactor |     Rename).

35. Show Files Home

Navigation Bar is a quick alternative to the Project view.
Use Alt+home keyboard shortcut to show the navigation bar, and arrow keys to locate the necessary files or folders.

36. Quickly open an Eclipse project

You can quickly open an Eclipse project by selecting A. Classpath or. project file in the file | Open dialog. The corresponding Eclipse project is imported with default settings, without launching the wizard.

37. Quickly find out where a class, method, variable is being used throughout the project Ctrl+alt+f7

You can bring forward the list of any usages of a class, method or variable across the whole project, and quickly jump to The selected usage. To does, place the caret at the symbol's name or at it usage in code and press

Ctrl+alt+f7 (Edit | Find | Show Usages in the main menu), scroll the list and click the desired usage.

38. Select the interface list

You can view all methods of the implemented interfaces in a class, if you place the caret at the Implements keyword in the class declaration, press CTRL+SHIFT+F7, and select the desired interface from the list:

39. View all the exit points in a method ctrl+shift+f7

To view all exit points of a method, place the caret at one of them, e.g. the return statement, and press Ctrl+shi FT+F7:

40. Quickly see which code throws an exception

You can view all statements within the method where certain exceptions can be caught. Just Place The caret at the throws keyword in a method declaration, press CTRL+SHIFT+F7 and select the desired exc Eption class from the list.

This would also work for     try and catch.

41. Create Test Cases

Android Studio helps create test cases directly from class declaration. With the caret at the same class name in the editor, press Alt+enter, and choose Create Test from the suggestion list:

42.

Learning---shortcut keys for Android Studio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.