The speed search is available in all the tree views : just start typing and you ‘ll quickly locate the necessary item;
The Esc key in any tools window moves the focus to the editor. Shift+Esc moves the focus to the editor and also hides the current(or last active) tool window.
The F12 key moves the focus from the editor to the last focused tool window.
When you want to catch some 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 will 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.
The SmartType code completion may be used after the new keyword, to instantiate an object of the expected type. For example, type
StringBuffer buffer = new
and press Ctrl + Alt + Blank
StringBuffer buffer = new StringBuffer();
When you need to cast an expression value to the required type the SmartType code completion will help you. For example , type
String s = (<caret is here>
and press Ctrl + Alt + Blank to see what happens
To navigate to the implementation(s) of an abstract method, position the caret at its usage or its name in the declaration and press Ctrl + Alt + B
Ctrl + W(extend selection) in the editor selects the word at the caret and the selects expanding areas of the source code. For example, it may select a method name, then the expression that calls this method, then the whole statement, then the containing ,block, etc. You can also select the word at the caret and the expanding areas of the source code by double-clicking the target areas in the editor.
The Extract Variable refactoring helps you simplify complicated statements in your code. For example, in the code fragment below , you can select an expression in the code:
myEditorPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
and press Ctrl + Alt + V (Refactor | Extract | Variable…). This will result in the following:
Border emptyBorder = BorderFactory.createEmptyBorder(5,5,5,5);
You can comment or uncomment lines and blocks of code using Ctrl + / and Ctrl + Shift + / .
Ctrl + / comments or uncomments the current line or selected block with single line comments(//…)
Ctrl + Shift + / encloses the selected block in a block comment(/…/).
To uncomment a commented block press Ctrl + Shift + / anywhere inside it.
To open your browser with documentation for the element at the editor’s caret, press Shift + F1 (View | External Documentation).
You must have the path to your browser set in the File | Settings | Web Browsers options and paths to documentation files added to your project (File | Project Structure…) to use this feature.
Ctrl + D in the editor duplicates the selected blocks or the current line when no block is selected.
Live Templates allow you to generate many typical code constructs in seconds! For example, type :
String [] array1,array2;
itar
in a method and press the Tab key to see what happens.
String [] array1,array2;
for(int i=0;i< arrary1.length;i++){
}
Use Ctrl + J to complete any valid Live template abbreviation if you don’t remember it. For example,type it and press Ctrl + J to see what happens.
The CodeCompletion feature can suggest a name for a variable when you declare it. For example, start typing:
private FileOutputStream
and press Ctrl + Blank
private FileOutputStream filOutputStream
When using basic code completion (Ctrl + Blank) ,type any characters that exist anywhere in an identifier.
Use Basic Completion (Ctrl+空格) within HTML, CSS and other files, for completing image file names.
If the cursor is between the parentheses of a method call, pressing Ctrl + P brings up a list of valid parameters.
Ctrl + Shift + BackSpace (Navigation | Last Edit Location) brings you back to the last place where you made changes in the code.
pressing Ctrl + Shift + BackSpace a few times moves you deeper into your changes history.
User Ctrl + Shift + F7(Edit | Find | Highlight Usages in File) to quickly highlight usages of some variable in the current file.
User F3 and Shift + F3 keys to navigate through highlight usages.
press Esc to remove highlighting.
Use Code | Reformat COde to format code according to your code style preferences (File | Settings | Code Style).
You 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).
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 will never lose ant code with this feature!
Press Alt + Q(View | Context Info) to see the declaration of the current method without the need to scroll to it.
Ctrl + E(View | Recent Files) brings a popup list of the recently visited files. Chose the desired file and press Enter to open it.
Besides recent files, you can bring results of the usage searches you have performed recently. To do that ,use the same Ctrl + E shortcut with the Find tool window having the focus, and select the desired find usages result from the Recent Find Usages popup.
Use F2 /Shift + F2 keys to jump between highlighted syntax errors.
Use Ctrl + Alt + Up/ Ctrl + Alt +Down shortcuts to jump between compiler error messages or search operation results.
To skip warnings right click on the validation side bar / marker bar choose Go to high priority problems only.
Use Ctrl + Alt + Up/ Ctrl + Alt +Down keys to quickly move between method in the editor.
To show separator lines between methods in the editor, open the editor settings and select the Show method separators check box in the Appearance page.
Ctrl + Shift + J shortcut joins two lines into one and removes unnecessary space to match your code style.
Use Refactor | Copy to create a class which is a copy of the selected class. This can be useful, for example,when you need to create a class which has much in common with some existing class and it’s not feasible to put the shared functionality in a common superclass.
Use the key shortcut to choose and insert recent clipboard contents into the text.
You can use the Extract Variable refactoring even on incomplete statements. Just press Ctrl+Alt+V, and choose the desired expression:
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.
Use Alt+Shift+C to quickly review your recent changes to the project.
By pressing Alt+Shift+F10 you can access the Run/Debug dropdown on the main toolbar, without the need to use your mouse.
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.
To quickly find a menu command or toolbar action, you do not need to look through the menus. Just press Ctrl+Shift+A (Help | Find Action on the main menu) and start typing the name of the action. Choose the desired action from the suggestion list.
Use Ctrl+Shift+I (View | Quick Definition), to quickly review definition or content of the symbol at caret, without the need to open it in a new editor tab.
Use Ctrl+Shift+Enter to complete a current statement such as if, do-while, try-catch, return (or a method call) into a syntactically correct construct (e.g. add curly braces).
With a single keystroke, you can apply another code style/coloring scheme or keymap right from the editor. Just press Ctrl+后引号 (View | Quick Switch Scheme), to specify the scheme you want to change.
To see the inheritance hierarchy for a selected class,press Ctrl + H (Navigaton| Type Hierarchy) . You can also invoke the hierarchy view right from the editor to see the hierarchy for the currently edited class.
Right-clicking on a breakpoint marker (on the bar to the left from the text) invokes the speedmenu where you can quickly enable/disable the breakpoint or adjust its properties.
When you are finding text in the current file (Ctrl+F), you don’t need to type the whole search string: Basic Code Completion is available in the search field. Start typing, press Ctrl+空格, and select the desired string from the suggestion list.
To view all exit points of a method, place the caret at one of them, e.g. the return statement, and press Ctrl+Shift+F7:
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 exception class from the list. This will also work for try and catch.
When you press Alt+Enter to invoke a quick fix or intention action, press the right arrow key to reveal the list of additional options.
Depending on the context, you can choose to disable inspection, fix all problems, change inspection profile, etc.
Ctrl+Click (on Windows) or Cmd+Click (on MacOS) a tab in the editor to navigate to any part of the file path. Select the necessary element in the drop-down, and the corresponding file path opens in an external browser (e.g., in the Explorer, if your OS is Windows).
Android Studio simplifies your work with colors in Android resource files. The color properties have the icons of the corresponding color in the left gutter area of the editor.
Click color icons to choose the desired color from the color picker.
Android Studio helps create test cases directly from class declaration. With the caret at the class name in the editor, press Alt+Enter, and choose Create Test from the suggestion list:
To easily evaluate the value of any expression while debugging the program, select its text in the editor (you may press a Ctrl+W a few times to efficiently perform this operation) and press Alt+F8.
Use the Switcher (Ctrl+Tab) to switch between open files and tool windows. Keeping Ctrl pressed, use the Up and Down arrow keys, Tab or Shift+Tab, Alt for navigation; use Delete or BackSpace to close editor tab or hide a tool window.
To compare two directories, select one or both of them in the Project view and press Ctrl+D.
To compare two jar files, select one or both of them in the Project view and press Ctrl+D.
To quickly evaluate the value of any expression while debugging the program, hold Alt and click this expression to see its value and calculate it, call a method, etc.
The shortcuts such as Ctrl+Q (View | Quick Documentation), Ctrl+P (View | Parameter Info), Ctrl+B (Navigate | Declaration) and others can be used not only in the editor but in the code completion popup list as well.
Use Basic Completion (Ctrl+空格) for completing words in text and comments in files of many different types.
All the words from the current file that start with the typed prefix will appear in the lookup list.When using Code Completion, you can accept the currently highlighted selection in the popup list with the period character (.), comma (,), semicolon (;), space and other characters.
The selected name is automatically entered in the editor followed by the entered character.To help you learn the purpose of each item in the main menu, its short description is shown in the status bar at the bottom of the application frame when you position the mouse pointer over this item.
For the pattern search in the Go to Class, Go to Symbol and Go to File pop-up frames, use * and space symbols.
* stands for any symbol.
Space at the end means the end of a pattern, and the preceding string will be considered not just a prefix but a whole pattern. The list of the suggested names will be reduced accordingly.When you invoke the Move refactoring (F6) on an inner class that is declared static, you are provided with an option to either make it a top-level class, or move it to another class.
You can start referring to an Ant property or target even if it is not defined yet. An intention action feature will suggest you to automatically create the necessary tag, without the need for you to leave your current editing location.
If nothing is selected in the editor, and you press Ctrl+C, then the whole line at caret is copied to the clipboard.
You can move any file to a changelist of your choice. To do that, just choose Move to Another Changelist on the file context menu in the Version Control tool window:
You can easily open an external file for editing, if you just drag it from the Explorer or Finder to the editor.