标签:
快捷键学习 TIPS:
1.异常代码块 或者自定义代码块结构 Ctrl+Alt+T 或者 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 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
想抓住一些代码块抛出的异常的时候,选择中,Ctrl+Alt+T 或者右键 (Code | Surround With) and choose try / catch
自定义块有很多,比如if ...if...等
2.代码完成 and press Ctrl+Shift+空格:
The SmartType code completion may be used after the new keyword, to instantiate an object of the expected type. For example, type
说的是new一个对象的时候,使用快捷键 Ctrl+Shift+空格:
3.实现抽象方法 Ctrl+Alt+B
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.
4. 提取变量进行重构,其实就是把一个很长的代码,缩减为几行,代码好看,并且把参数独立出来,重新申请一个变量,这样出错了容易找到是哪个问题 Ctrl+Alt+V
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:
and press Ctrl+Alt+V (Refactor | Extract | Variable...). This will result in the following:
5.注释 跟ADT里面类似 Ctrl +斜杠 代表的意思是:// ;Ctrl + Shift +斜杠 代表的是 /*…*/
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.
6.
Ctrl+D in the editor duplicates the selected block or the current line when no block is selected.
7.制表符键
Use the Tab key to move between the template fields. See File | Settings | Live Templates for more details.
8.提示 变量名称 Ctrl+空格
The CodeCompletion feature can suggest a name for a variable when you declare it. For example, start typing
private FileOutputStream
and press Ctrl+空格.
9.查看方法的 参数类型有哪些 Ctrl+P
If the cursor is between the parentheses of a method call, pressing Ctrl+P brings up a list of valid parameters.
10.代码回退 就是操作历史吧 Ctrl + Shift +退格键
Ctrl+Shift+Backspace (Navigate | 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.
11.使变量突出 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.格式化代码 Code | Reformat Code
Use Code | Reformat Code to reformat 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.
13.回滚历史代码 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 will never lose any code with this feature!
14.查看方法的申明 Alt+Q
Press Alt+Q (View | Context Info) to see the declaration of the current method without the need to scroll to it.
15.打开最近访问的文件 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.错误语法之间快速跳跃
Use F2/Shift+F2 keys to jump between highlighted syntax errors.
Use Ctrl+Alt+向上箭头/Ctrl+Alt+向下箭头 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.快速敲出变量名 Ctrl+J
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.
18.方法之间添加分隔符
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.
19.在两个方法之间快速的移动
Use Alt+向上箭头 and Alt+向下箭头 keys to quickly move between methods in the editor.
20.删除不必要的空格 Ctrl+Shift+J
Ctrl+Shift+J shortcut joins two lines into one and removes unnecessary space to match your code style.
21.构建一个类的副本
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.
22.剪切和插入一段代码
Use the Ctrl+Shift+V shortcut to choose and insert recent clipboard contents into the text.
23.查看一个类的层级结构 层次结构 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-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.
25.调试的时候评估一个表达式的值
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.
26.查看定义说明 Ctrl+Q
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.
27.更改内部类
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.
28.打开任何一个变量或者方法 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.快速回顾最近更改的项目
Use Alt+Shift+C to quickly review your recent changes to the project.
30.代码快速补充 Ctrl+空格
Use Basic Completion (Ctrl+空格) within HTML, CSS and other files, for completing image file names.
31.灯泡标识 提示 自动创建 变量,从而不用离开当前的编辑位置
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.
32.补齐 大括号{} Ctrl+Shift+Enter
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).
33.调试运行
By pressing Alt+Shift+F10 you can access the Run/Debug dropdown on the main toolbar, without the need to use your mouse.
34.重命名
It is possible to rename CSS selectors directly from HTML. Position the caret at the selector to be renamed and press Shift+F6 (Refactor | Rename).
35.显示文件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.快速打开一个eclipse项目
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.快速找到一个类、方法、变量在整个项目中哪些地方被使用 Ctrl+Alt+F7
You can bring forward the list of all usages of a class, method or variable across the whole project, and quickly jump to the selected usage. To do that, place the caret at the symbol‘s name or at its 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.选择接口列表
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.查看一个方法中 所有的退出点 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+Shift+F7:
40.快速查看哪些代码会抛出异常
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.
41.创建测试用例
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:
42.
标签:
原文地址:http://www.cnblogs.com/wust221/p/5426147.html