標籤:
快速鍵學習 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.
android studio學習---快速鍵