Android Studio 快捷用法

AndroidStudio已經用了兩年左右了,對快捷鍵的使用一直如同段譽的六脈神劍通常,偶爾會biu不出來,歷來沒有靜下心來耐心的看完Tips,爲了不這種尷尬,決定把Tips完整的練習一遍並記錄在案。html

AndroidStudio版本:2.2 java

計算機操做系統: Windows 7node

提示 ##
若是關閉了提示對話框,可在 Help | Tip of the Day 打開。android

Welcome to Android Studio 2.2 You can quickly get familiar with the main features of the IDE by reading these tips.
You may try out the features described in the tips while this dialog stays open on the screen.
If you close the dialog, you can always get back to it from the Help | Tip of the Day main menu item.shell

Ctrl + N

在編輯器中 Ctrl + N 搜索
也可使用Ctrl+Shift+N搜索項目中的任意文件express

To open any class in the editor quickly, press Ctrl+N (Navigate | Class) and start typing the name of the class. Choose the class from a drop-down list that appears.
Ctrl + Nwindows

You can open any file in your project in a similar way by using Ctrl+Shift+N (Navigate | File)api

Ctrl+空格

代碼補全提示,和搜狗輸入法默認快捷鍵會衝突,修改便可瀏覽器

其實AndroidStudio在一次完整的輸入會默認具備使用Ctrl+空格的效果。
除非是輸入中斷後才須要再次使用Ctrl+空格作補全提示。
好比輸入過程當中鼠標焦點切換至tool window,再次切換回編輯器才須要手動Ctrl+空格喚起補全提示。)app

The Code Completion feature lets you quickly complete different kinds of tatements in the code.
For example, start typing a class name and press Ctrl+空格 to complete it. When multiple choices are available, they are shown in the lookup list.
Ctrl+空格

提供建議的變量名稱

The CodeCompletion feature can suggest a name for a variable when you declare it. For example, start typing
 private FileOutputStream
and press Ctrl+空格.
Ctrl+空格

You can customize name prefixes for local variables, parameters, instance and static fields in File | Settings | Code Style.

提示已存在(自定義)的方法

When using basic code completion (Ctrl+空格), type any characters that exist anywhere in an identifier.
Ctrl+空格

提供多種類型文件的提示,如圖所示的HTML文件。

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.
Ctrl+空格

HTMLCSS等文件中提供圖片名稱(Local圖片)提示。

Use Basic Completion (Ctrl+空格) within HTML, CSS and other files, for
completing image file names.
Ctrl+空格

甚至包含HTMLCSSJavaScript文件中的屬性、參數、標籤、選擇器等。

You can use Basic Completion (Ctrl+空格) in HTML, CSS and JavaScript files, for completing attributes, parameters, tags, selectors, etc.
Ctrl+空格

You can use Basic Completion (Ctrl+空格) within Java String literals and in other file types, for completing .properties keys.
Ctrl+空格

輸入多個小寫字母,智能對應被提示方法的駝峯每一個單詞首字母

When using basic code completion (Ctrl+空格), you don't need to type upper-case letters in CamelHump names. It is enough to type the initial letters of the camel names in lower case, and they will be smartly recognized.
Ctrl+空格

Show Usages

快速查找被使用位置

You can quickly find all places where a particular class, method or variable is used in the whole project by positioning the caret at the symbol's name or at its usage in code and pressing Alt+F7 (Edit | Find | Find Usages in the popup menu).

相比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.
Show Usages

Ctrl+Q

快速查看文檔(插入符所定位的類或方法)

To quickly see the documentation for a class or method at caret, press Ctrl+Q (View | Quick Documentation).
Ctrl+Q

Ctrl+B

跳轉至聲明位置。
插入符放在類、方法、變量使用處,點擊Ctrl+B即跳轉至聲明位置,等同於按下Ctrl時鼠標單擊效果。(經測試:在聲明處使用也可跳轉至使用處)

To navigate to the declaration of a class, method or variable used somewhere in the code, position the caret at the usage and press Ctrl+B (Navigate | Declaration). You can also click the mouse on usages with the Ctrl key pressed to jump to declarations.Ctrl+B

Ctrl+F12

顯示大綱/文件結構

You can quickly navigate in the currently edited file with Ctrl+F12 (Navigate | File Structure). It shows the list of members of the
current class. Select an element you want to navigate to and press the Enter key or the F4 key. To easily locate an item in the list, just start typing its name.

Shift+F6

重命名 類、方法、變量名稱,並自動修改全部引用。

You can easily rename your classes, methods and variables with automatic correction of all places where they are used.
To try it, place the caret at the symbol you want to rename, and press Shift+F6 (Refactor | Rename). Type the new name in the popup window that appears, or select one of the suggested names, and press Enter.
Shift+F6

Ctrl+O

Ctrl+O重寫父類方法,Ctrl+I實現接口方法

You may easily override methods of the base class by pressing Ctrl+O (Code | Override Methods).
To implement methods of the interfaces that the current class implements (or of the abstract base class), use Ctrl+I (Code | Implement methods).

Ctrl+Shift+空格

自動補全代碼

The SmartType code completion greatly helps to find methods and variables that are suitable in the current context, by analyzing the expected type of the whole expression. So doing, Android Studio pinpoints the top five most suitable results and highlights them on the green background. For example, type
Ctrl+Shift+空格

and press Ctrl+Shift+空格:

 Ctrl+Shift+空格_1

The SmartType completion also works after the return keyword, in an assignment, in an argument list of a method call and other places.

The SmartType code completion may be used after the new keyword, to instantiate an object of the expected type. For example, type
new

and press Ctrl+Shift+空格:
new

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+Shift+空格 to see what happens.

Tab&Enter

When using Code Completion, you can accept the currently highlighted selection in the popup list with Tab key.
Unlike accepting with the Enter key, the selected name will overwrite the rest of the name to the right of the caret. This can be especially useful for replacing one method or variable name with another.

Shift+click

關閉選項卡,Alt + Click關閉其餘選項卡

Did you know that you can close tabs in the editor and the tool windows of Android Studio without actually using the context menu commands? It is enough to point with your mouse cursor to a tab to be closed, and click the middle mouse button, or just use the Shift+click combination.

Alt+Insert

生成構造函數、Getter and Setter、toString()等方法。

Using Alt+Insert (Code | Generate) in the editor, you can easily generate getter and setter methods for any fields of your class.
Alt+Insert

Alt+F1

如圖所示,能夠快速切換到不一樣的視圖:項目視圖(Project, Packages, Android)、文件結構、在Exporler中顯示等等。

To quickly select the currently edited element (class, file, method or field) in any view (Project view, Structure view or other), press Alt+F1.
Alt+F1

speed search in the tree views

在樹視圖中快速查找:鼠標選中樹輸入名稱便可。

The speed search is available in all the tree views: just start typing and you'll quickly locate the necessary item.
speed search

Focus of the Editor

焦點移動:

  • Esc 焦點從工具窗口移動至編輯器

  • Shift+Esc 關閉當前(最後一個)工具窗口並將焦點移動至編輯器

  • F12 焦點從編輯器移動至最後聚焦工具窗口

The Esc key in any tool 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.

Ctrl+Alt+T

生成try / catchiffor等代碼模板

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

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.

Ctrl+W

選擇範圍,屢次點擊後逐漸擴大,如:選擇方法中某個方法引用,屢次點擊Ctrl+W,方法表達式 > 該行 > 包含塊 > 整個方法 > 整個類塊

Ctrl+W (extend selection) in the editor selects the word at the caret and then 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.

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:
Ctrl+Alt+V

and press Ctrl+Alt+V (Refactor | Extract | Variable...). This will result in the following:
Ctrl+Alt+V

選擇一個表達式後使用Ctrl+Alt+V 會生成一個變量並被引用,並且能夠選擇變量名。
如圖:選擇第一行的綠色區域表達式,則會生成第五行的變量並被第六行引用。

You can use the Extract Variable refactoring even on incomplete statements. Just press Ctrl+Alt+V, and choose the desired expression:
Ctrl+Alt+V

comment or uncomment

生成註釋與取消註釋

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.

Shift+F1

在瀏覽器中打開文檔。

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

在編輯器複製所選塊,若是未選則複製當前行。

Ctrl+D in the editor duplicates the selected block or the current line when no block is selected.

Try Live Templates

使用Live Templates, 經常使用的好比 Toast,能夠在設置中自定義經常使用模板。
文中所說的Tab切換字段測試未生效

Try Live Templates
Live Templates allow you to generate many typical code constructs in seconds! For example, type
Live Templates

in a method and press the Tab key to see what happens.
Live Templates

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

Ctrl+P

光標在方法的括號之間,點擊Ctrl+P能夠調出參數列表

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

Ctrl+Shift+Backspace

單次Ctrl+Shift+Backspace能夠返回至最後一次修改位置,屢次調用則返回更久的歷史修改位置

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.

Ctrl+Shift+F7

相似Find查詢方法

Ctrl+Shift+F7高亮顯示所選變量,F3Shift+F3分別向上和向下跳轉,
Esc 退出高亮模式。

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.

view all methods of the implemented interfaces in a class

光標在implemented處按Ctrl+Shift+F7 查看類中全部的接口實現方法。
經測試不會如圖彈出框,而是將實現方法在編輯器中高亮顯示並在IntelliJ IDEA底部欄顯示數量等提示。

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:
Ctrl+Shift+F7

view all statements within the method where certain exceptions can be caught

查看方法中全部能夠捕獲異常的語句:將光標放在方法聲明中的throws關鍵字處,按Ctrl + Shift + F7並從列表中選擇所需的異常類,該功能對try catch一樣適用。

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.
Ctrl+Shift+F7

Reformat Code / Optimize Imports

格式化代碼/優化引用

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.

Local History | Show History

文件右鍵選擇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!

Alt+Q

不用滾動便可查看當前方法聲明所在類

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

Ctrl+E

Ctrl+E 在編輯器中使用,會彈出最近訪問文件列表
在工具窗口使用,會彈出最近 查詢使用(Find Usages)列表

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

Besides recent files, you can bring up 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.

Ctrl+E

Go to high priority problems only

使用F2/Shift+F2 能夠在高亮錯誤間上下跳轉。
使用Ctrl+Alt+向上箭頭/Ctrl+Alt+向下箭頭 能夠在編譯錯誤間上下跳轉,search operation results是什麼不瞭解。

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.

Ctrl+J / valid Live Template abbreviation

Ctrl+J調出Live Template可用列表

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.
Ctrl+J

Show method separators

設置顯示方法線,視覺上更容易分隔方法

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.
Show method separators

move between methods in the editor

Alt+向上箭頭Alt+向下箭頭 在方法間快速上下跳轉

Use Alt+向上箭頭 and Alt+向下箭頭 keys to quickly move between methods in the editor.

Ctrl+Shift+J / joins two lines into one

Ctrl+Shift+J 可將多行合併成一行代碼

Ctrl+Shift+J shortcut joins two lines into one and removes unnecessary space to match your code style.

Refactor | Copy

複製當前類

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.

Ctrl+Shift+V

Ctrl+Shift+V 顯示 最近粘貼板內容列表,可供選擇

Use the Ctrl+Shift+V shortcut to choose and insert recent clipboard contents into the text.

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.
Ctrl+H

breakpoint marker

設置好斷點後,在斷點上右鍵顯示的快捷菜單中,能夠快速啓用/禁用、調整其屬性(設置觸發條件單次觸發後移除等)

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.
breakpoint marker

evaluate the value of any expression

調試中能夠經過Alt+F8計算所選表達式值

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.

也能夠經過 按住Alt鍵而後點擊表達式計算值

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.

evaluate the value of any expression

Ctrl+Q

Ctrl+Q 快速查看文檔
Ctrl+P 查看參數信息
Ctrl+B 跳轉至聲明處

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.
Ctrl+Q

accept the currently highlighted selection in the popup list

本身kuo mo

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.

short description of main menu

爲了幫助瞭解主菜單的每一項功能,鼠標放在按鈕上後顯示該功能描述

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.

pattern search

模糊查詢

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.
pattern search

Move refactoring on an inner class that is declared static

靜態內部類重構:在靜態內部類中點擊F6 彈出提示框,可選擇升級成頂級類(即新建一個類文件)或移動至其餘類中(仍然是靜態內部類)

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.
F6

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.
Ctrl+Alt+Shift+N

Alt+Shift+C

快速查看最近對項目所作的更改

Use Alt+Shift+C to quickly review your recent changes to the project.
Alt+Shift+C

Ant property or target

使用Ant屬性,不存在能夠在當前界面快速建立

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.
 Ant property or target

Quick Switch Scheme

快速切換主題切換顏色方案切換代碼樣式方案切換快捷鍵方案切換外觀

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.
Quick Switch Scheme

Ctrl+Shift+Enter

使用Ctrl + Shift + Enter完成當前語句,如ifdo-whiletry-catchreturn(或方法調用)到語法正確的結構中(例如添加花括號

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).
Ctrl+Shift+Enter

camel words

When in the Go to Class, Go to Symbol, or Go to File popup, you can ease the search by filtering the lookup list with the help of the "camel words" prefixes.
camel words

Quick Definition

查看方法定義:在接口和父類中點擊Ctrl+Shift+I可查看子類和實現類,若是有多個定義可經過Back(向左箭頭)和Forward(向右箭頭)切換,Show Source(Ctrl+Enter)查看,Edit Source(F4)修改

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.
Ctrl+Shift+I

Copy Reference

使用Ctrl+Alt+Shift+C複製完整引用。

The Edit | Copy Reference action can be used to insert a reference to a field/method/class/file into the current position in the editor. For example, go to the java.util.Collections JDK class, place the cursor within the EMPTY-MAP field and press Ctrl+Alt+Shift+C:
Ctrl+Alt+Shift+C

Then return to your source code and press Ctrl+V:
Ctrl+Alt+Shift+C

You can also copy references in the GotoClass/GotoSymbol/GotoFile dialogs. Just press Ctrl+C on any element in the lookup list.

Move Statement Up/Down

Ctrl+Shift+向上箭頭Ctrl+Shift+向下箭頭 能夠向上向下移動代碼

The Code | Move Statement Up/Down action is useful for reorganizing the code lines in your file, e.g., for bringing a variable declaration closer to variable usage.
Select a code fragment and press Ctrl+Shift+向上箭頭 or Ctrl+Shift+向下箭頭.
The following pictures show an initial location of a code fragment, and the results of moving the selected fragment up and down.
When nothing is selected in the editor, the line at the cursor will be moved.
Move Statement Up/Down

Run/Debug dropdown

Alt+Shift+F10 能夠訪問Run/Debug下拉菜單

By pressing Alt+Shift+F10 you can access the Run/Debug dropdown on the main toolbar, without the need to use your mouse.

Quick Definition Viewer

本身kuo mo

The Quick Definition Viewer (Ctrl+Shift+I) can also be used for items in lookup lists that appear on code completion and class/file/symbol navigaton commands.
Quick Definition Viewer

Show Applied Styles For Tag

選中HTML標籤 右鍵選擇Show Applied Styles For TagTool Window 即顯示應用的樣式列表

You can quickly review all styles currently applied to an HTML tag, by right-clicking the tag name and selecting Show Applied Styles For Tag from the context menu:
Show Applied Styles For Tag

view the image referenced at caret

本身kuo mo

You can quickly view the image referenced at caret by using the Quick Definition (Ctrl+Shift+I). The underlying image will be opened in a popup instead of a separate editor tab.
view the image referenced at caret

Refactor | Rename

能夠直接從HTML重命名CSS選擇器

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).

shortcut to show the navigation bar

使用Alt + 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.
shortcut to show the navigation bar

shortcut to show or hide this tool window

Changes工具窗口在單個視圖中顯示全部已刪除,已修改和未版本化的文件。
並能夠執行全部必要的版本控制操做:提交更改管理更改列表添加資源至版本控制檢查差別等。

使用Alt + 9顯示或隱藏此工具窗口。

The Changes tool window shows all deleted, modified, and unversioned files in a single view. Use Alt+9 keyboard shortcut to show or hide this tool window.
From the Changes tool window you can perform all the necessary version control actions: commit changes, manage changelists, put resources under version control, examine differences and more.

antivirus protection

防病毒保護

If you notice that Android Studio works slowly, consider the possibility to reduce the number of folders under antivirus protection.
Each antivirus check in your project consumes resources. You can significantly improve the performance, if you exclude certain folders from the antivirus protection.

quickly open a Maven project

選擇pom.xml 文件便可打開Maven項目

You can quickly open a Maven project by selecting a pom.xml file in the File | Open dialog. The corresponding Maven project is imported with default settings, without launching the wizard.

Shelve Changes

擱置更改

If you don't want to commit some of your changes to the repository, you can set them aside for a while, by moving to a separate changelist, or by putting them to a shelf. Select such file in the Local tab of the Changes tool window, and on the context menu choose Move to Another Changelist, or Shelve Changes.

quickly open an Eclipse project

快速打開一個Eclipse項目:選擇.classpath或者.project文件,相應的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.

quickly find a menu command or toolbar action

快速找到菜單命令或工具欄操做:只需按Ctrl + Shift + A(主菜單上的Help | Find Action」),而後開始輸入操做名稱,而不須要查看菜單。

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.

quickly find and run an inspection

inspectionlintAndroidStudio提供的代碼靜態分析工具,能夠檢查項目中存在的問題(xml文件中是否存在hardcode未用到的資源可能存在的bug等等),改善項目以幫助開發出規範的App。

inspection 檢查項能夠在 Settings | Editor | Inspection 查看,也能夠配置單項的嚴重程度和做用域。

快速查找並運行檢查:按Ctrl+Alt+Shift+I後輸入須要查詢項名或組名,而後在列表中選擇後開始檢查

To quickly find and run an inspection, press Ctrl+Alt+Shift+I and start typing the name of the inspection or its group. Choose the desired inspection from the suggestion list and then specify the desired scope.

Inspection

quickly find a setting

快速查詢設置:Ctrl + Alt + S 打開設置,可在搜索框輸入搜索。

You can quickly find a setting you need in the Settings/Preferences dialog, without browsing through the numerous options. Just type some characters that, in your opinion, exist in the option description, and the list of settings will reduce to the matching ones. Select the desired entry, and see the setting that contains the entered characters highlighted:
quickly find a setting

searching for a text string in a file

在文件中搜索文本字符串時,可用向下箭頭顯示最近輸入的列表

When searching for a text string in a file, use recent history: with the search pane already open, click the down arrow to show the list of recent entries.
searching for a text string in a file

finding text in the current file

在當前文件中查找文本(Ctrl + F)時,不須要輸入整個搜索字符串:可使用代碼提示功能,輸入部分字母按Ctrl +空格,從彈出的建議列表中選擇所需字符串。

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.
finding text in the current file

To view all exit points of a method

查看方法全部出口點,如 return語句break語句
光標放在某一出口點,按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:
To view all exit points of a method

invoke a quick fix or intention action

Alt+Enter快速修復

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.
invoke a quick fix or intention action

navigate to any part of the file path

導航到文件的任何層級(父)目錄:Ctrl+Click (Windows) or Cmd+Click (MacOS)點擊後,彈出從盤符到文件所在目錄間的全部目錄,選擇所需目錄後會在資源管理器中打開(MacOS系統在外部瀏覽器中打開)。

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).
navigate to any part of the file path

Issue Navigation

Android Studio 能夠從註釋添加頁面跳轉至問題跟蹤器,問題跟蹤器能夠在Settings | Version Control | Issue Navigation 中定義。
提交更改列表並輸入註釋時,保證問題導航模式能夠匹配。稍後瀏覽Repository中的更改列表時,此類註釋將變爲超連接。
單擊超連接可跳轉至任務跟蹤器中的問題。

Android Studio lets you jump from your check-in comment to an issue in your task tracker.
All you have to do is to define issue navigation patterns in the Settings | Version Control | Issue Navigation dialog:
Issue Navigation

When you commit a changelist, and type the check-in comment, make sure it matches one of your issue navigation patterns. Later, when you browse through the changelists in the repository, such comments turn into hyperlinks:
commit a changelist

Clicking a hyperlink brings you directly to an issue in your task tracker

choose the desired color from the color picker

從顏色選擇器中取色:Android Studio簡化了CSS文件中取色,顏色屬性在編輯器的左側溝槽有相應顏色的圖標,點擊顏色圖標能夠打開顏色選擇器取色

Android Studio simplifies your work with colors in CSS 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.
choose the desired color from the color picker

Create Test

Android Studio 幫助直接從類聲明建立測試用例。光標定位在編輯器中的類名稱處,按Alt + Enter,而後從建議列表中選擇建立測試

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:
Create Test

easily make column selection

同時選擇多行,如 Sublime Text
Alt鍵的同時拖動鼠標便可進行列選擇。

You can easily make column selection by dragging your mouse pointer while keeping the Alt key pressed.
easily make column selection

File Colors

文件顏色能夠在Appearance & Behavior | File Colors設置(自定義顏色),也能夠添加Scope(域)。

You don't need to guess which index.html file you are looking at...
Make the editor tabs and lines in navigation lists stand out using the File Colors page of the project settings.
File Colors

whole line at caret is copied

若是在編輯器中不選中任何內容,按 Ctrl + C會複製光標所在的整行內容

If nothing is selected in the editor, and you press Ctrl+C, then the whole line at caret is copied to the clipboard.

Move to Another Changelist

你能夠將任何文件移動至選擇的更改列表中:在Local Changes中選中文件右鍵Move to Another Changelist選擇便可。

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 Changes tool window:
Move to Another Changelist

pre-defined dictionaries

內置的拼寫檢查器的幫助下,保持源代碼不會出現錯別字。
預約義的字典將會檢查全部文本,包括註釋字符串文字全部錯別字都會突出顯示,這樣就能夠選擇正確的單詞,接受當前拼寫或禁用檢查。
Alt + Enter查看可用操做的列表。

Keep your source code typo-free with the help of the built-in Spellchecker.

All texts, including comments, textual strings and literals, are inspected against the pre-defined dictionaries. All typos are highlighted, which leaves you with the task of choosing the correct word, accepting the current spelling, or disabling inspection.

Use Alt+Enter to see the list of available actions.

custom dictionary

若是在預約義的詞典中缺乏詞語,能夠建立本身的詞典。自定義詞典只是一個具備.dic擴展名的文本文件,每一個單詞從一個新行開始。
Editor | Spelling 中經過Dictionaries添加.dic文件存儲目錄便可,也可經過Accepted Words添加單詞。

If you lack words in the pre-defined dictionaries, you can create your own ones. A custom dictionary is a mere textual file with a .dic extension, with each word starting on a new line.
All you have to do is to point to the directories where your dictionaries are stored, in the Spelling of the Settings dialog.

VCS Operations

全部必需的VCS命令只需點擊一下便可。
Alt+後引號,或在主菜單選擇VCS | VCS Operations Popup即彈出VCS命令選擇列表。

All your most indispensable VCS commands are just one-click away...
Choose VCS | VCS Operations Popup on the main menu, and get a popup with the VCS commands that are relevant to the current context:
VCS Operations

Use the Switcher

使用切換器(Ctrl + Tab)在打開的文件和工具窗口之間切換。
按住Ctrl鍵,使用向上向下箭頭鍵,TabShift + TabAlt進行導航;使用DeleteBackSpace關閉編輯器選項卡或隱藏工具窗口。

經測試:彈出切換器後,用Ctrl+方向鍵更方便。

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.
Use the Switcher

open an external file for editing

將文件從ExplorerFinder 拖入編輯器就能夠打開外部文件。

You can easily open an external file for editing, if you just drag it from the Explorer or Finder to the editor.
open an external file for editing

closing all tabs in the editor

有兩種方法關閉編輯器中的其餘(全部)選項卡。

  • 在選項卡上右鍵,選擇Close Others

  • 按住Alt鍵,單擊編輯器選項卡關閉按鈕

There are two ways of closing all tabs in the editor, except the current one:

  • First, right-click the editor tab, and choose Close Others on the context menu.

  • Second, keeping the Alt key pressed, click close button on the editor tab.
    closing all tabs in the editor

jump directly to any deeply buried file

能夠直接跳轉到深層級文件,若是你按Ctrl + Shift + N,並只輸入幾個字符的封閉目錄和文件名。

例如 MyProject/toplevelDir/level1Dir/level2Dir/level3Dir/deeplyBuriedFile.html

  • 只須要輸入t/l/l/d 便可查詢到deeplyBuriedFile.html文件。

  • 輸入l/l/可查詢到level2Dirlevel3Dir

You can jump directly to any deeply buried file, if you press Ctrl+Shift+N, and type just a couple of characters of the enclosing directories and file names:
jump directly to any deeply buried file
Use either a slash or a backslash as a delimiter.

open any class or file in the editor

打開項目中的任意文件定位到指定行: [文件匹配內容]:[行數],以下圖

To open any class or file in the editor at the desired line, press Ctrl+Shift+N (Navigate | File), start typing the name, and choose the one from the suggestion list. Then type the colon (:) and a line number.
The selected file will open with the caret at the specified line.
open any class or file in the editor

Show Diff of Version control

顯示版本控制的差別

Version control annotations show the latest changes of each line in one click.
Just right-click an annotation and use the Show Diff command in the context menu.
Show Diff

compare two directories

比較兩個目錄:在項目視圖中選擇目錄,按Ctrl+D即彈出比較窗口。

To compare two directories, select one or both of them in the Project view and press Ctrl+D.

hide/show the tool windows bars

點擊左下角圖標button 能夠隱藏工具窗口,雙擊Alt,工具窗口暫時顯示。

If you need more workspace, you can hide the tool windows bars: click button in the lower left corner.
If necessary, you can show the tool window buttons just for a moment. To do that, press the key Alt (for Windows/*nix) or Command (for Mac) twice and keep it down. While the key is pressed, the tool window buttons are visible.

exclude any file from your project

純文本會被索引檢查代碼完成功能忽略:文件右鍵後選擇標記爲純文本,標記成功也能夠右鍵取消標記。
測試時未發現該功能

You can exclude any file from your project. As a result, such a file will be ignored by indexing, inspection and code completion.
In the Project tool window, select the file you want to ignore, and choose Mark as plain text in its context menu.
If necessary, you can always return the file to its original type using the Mark as <file type> context menu command.

Commit Changes

Ctrl + K 快速調用 「提交更改」 對話框。對話框顯示項目中的全部修改,提供文件狀態的概要信息,並在提交以前提出改進建議。
改進意見:經過代碼分析,提示Review, 選擇Review後在工具欄顯示建議列表。

The keyboard shortcut Ctrl+K enables you to quickly invoke the Commit Changes dialog.
This dialog shows all modifications in project, gives summary information of file status and suggests improvements before check-in.

toggle between find and replace

搜索替換間切換:按下Ctrl+F後顯示搜索面板,按Ctrl+R後添加內容,能夠替換搜索內容。按下Ctrl+Shift+R彈出替換彈出框,能夠更多選項如:預覽做用域過濾條件

It is very easy to toggle between find and replace functionality.
When you perform search and replace in a file, pressing Ctrl+F shows the search pane. Pressing Ctrl+R adds field, where you can type the replace string.
While in the Find in Path dialog, you can switch to replace by pressing Ctrl+Shift+R. Same way, press Ctrl+Shift+F to hide the Replace with field, and switch to mere search.

Scope-Based

若是你一個大型項目,使用多個TODO項目,請按範圍進行過濾。
使用TODO工具窗口中的「基於範圍」選項卡僅顯示與感興趣範圍相關的項。

If you are working on a large project, with numerous TODO items, filter them by scopes.
Use the Scope-Based tab in the TODO tool window to show only those items that pertain to the scope of interest.
Scope-Based

TODO tool window

代辦工具窗口能夠經過Preview Source預覽每項代辦事項。

TODO tool window lets you preview each of the encountered TODO items - just click the preview button on the toolbar.
TODO tool window

method signature quick fix

方法簽名快速修復:若是方法簽名已更改(包括參數、返回值等),Android Studio會突出顯示與文檔註釋不一樣步的代碼,並建議快速修復。

If a method signature has been changed, Android Studio highlights the tags that ran out of sync with the documentation comment and suggests a quick fix:
method signature quick fix

Remove the tasks

使用冗長的任務列表時,不須要逐個刪除它們。選擇幾個任務,使用ShiftControl / Command鍵,單擊向右箭頭,而後單擊刪除。

When working with a lengthy list of tasks, you don't need to delete them one by one. Select several tasks, using Shift or Control/Command keys, click the right arrow, and then click Remove.
Remove the tasks

run/debug group

若是有太多的相同類型的運行/調試配置,能夠將它們分組到文件夾。

If there are too many run/debug configurations of the same type, you can group them into folders, and thus distinguish them visually.
run/debug group

Live Templates

Settings | Live Templates頁面中能夠快速搜索模板。

In the Live Templates settings, use speed search to find templates with certain text in the template abbreviation, body or description.
Start typing the desired text, and the list of available templates will shrink to show matching templates only:
Live Templates

Edit RegExp

You can avoid escaping backslashes in your regular expressions. Start typing a regular expression, then press Alt+Enter and choose Edit RegExp. The regular expression opens in a separate tab in the editor, where you can type backslashes as is.
All changes are synchronized with the original regular expression, and escapes are presented automatically. When ready, just press Esc to close the regular expression editor.
Edit RegExp

Editor | Emmet

Speed up HTML, XML or CSS development with Emmet.
Enable this framework in the corresponding page of the Editor | Emmet node (Settings/Preferences):
Editor | Emmet

*.properties

All escaped characters in the *.properties files in the format \uXXXX, are displayed in the resource bundle editor as un-escaped unicode literals.
Vice versa, if a non-ASCII character is entered in the resource bundle editor, it is reflected in the underlying *.properties file as a corresponding escaped character in the format \uXXXX.
For example, if the *.properties file contains a property value
*.properties
then the resource bundle editor will show
*.properties

line separators

To view which line separators style is used in the current file, look at the Status Bar:
line separators
To change the current line ending style, just click the spinner.

line separators

You do not need to open a file in the editor to change its line separator style. Use the Project tool window instead: select one or more files, or folders, point to File | Line Separators on the main menu, and then choose the desired line ending style.
For a directory, new line separator applies recursively.
line separators

list of refactorings

If you place the caret at certain symbol and press Ctrl+Alt+Shift+T, you will see the list of refactorings applicable to the current context.
list of refactorings

Favorites

You want your bookmarks and breakpoints to be always at hand, so that you can easily navigate through them?
They are visible in the Favorites tool window, which you can dock or float as required:
Favorites

drop file onto the Favorites tool window

You can drag an external file from the Explorer or Finder, and drop it onto the Favorites tool window.
drop file onto the Favorites tool window

Tune the Android Studio tool windows layout

Tune the Android Studio tool windows layout to make better use of your screen.
Toggle between the vertical and side-by-side placement of the tool windows by Ctrl+Click/Cmd+Click on the splitter:
Tune the Android Studio tool windows layout

Terminal

You don't need to leave Android Studio to work with your favorite shell. Just click the Terminal tool window button, and enjoy using the embedded local terminal.
Terminal

define your favorite shell

For the embedded local terminal, you can define your favorite shell, default tab name, and other settings. Choose File | Settings on the main menu, and then open the page Terminal.

Enable the horizontal scrolling

Enable the horizontal scrolling with the mouse wheel by holding the Shift key.

double pressing the Shift key

Android Studio allows you to search through the classes, files, tool windows, actions, settings, and symbols of your project by double pressing the Shift key.

autopopup Code

When using autopopup Code Completion, you can select the first item using Ctrl+句點. The selected name is automatically entered in the editor followed by dot.

close autopopup

When an autopopup completion is active, Ctrl+向下箭頭 and Ctrl+向上箭頭 will close it and move the caret down or up in the editor.

"camel words" ease the search

When in the Code Completion lookup, you can ease the search by filtering the list with the help of the "camel words" prefixes.
"camel words" ease the search

suggest to get an element from this array

Pressing the same shortcut after you have invoked Smart-type Completion when there's an array of expected type in context will suggest to get an element from this array.
suggest to get an element from this array

suggest to convert searched for arrays using Arrays.asList() call

Pressing the same shortcut after you have invoked Smart-type Completion when a collection type is expected will search for arrays with same component type and suggest to convert them using Arrays.asList() call.
suggest to convert searched for arrays using Arrays.asList() call

search for chained expressions

Pressing the same shortcut after you have invoked Smart-type Completion will search for chained expressions which have expected type.
search for chained expressions

accept the currently highlighted selection in the popup list

When using Code Completion, you can accept the currently highlighted selection in the popup list with the Ctrl+Shift+Enter, Android Studio will not just insert the selected string, but also will do its best to turn current code construct into syntactically correct one (balance parentheses, add missing braces and semicolons, etc.)

accept the currently highlighted selection in the popup list In Java

When using Code Completion in Java, you can accept the currently highlighted selection in the popup list with the exclamation sign (!) character. It will be inserted before the boolean method or variable you were completing, thus negating the whole expression.
accept the currently highlighted selection in the popup list In Java

After pressing '!':
accept the currently highlighted selection in the popup list In Java

method to be imported statically

To quickly complete a method call of a static method located anywhere in your project, libraries or JDK, enter a prefix and press Ctrl+空格 twice. You'll see all the matching methods. If you want the method you chose to be imported statically, press Alt+Enter and see what happens:
method to be imported statically

view all accessible classes

When you invoked Basic Completion (Ctrl+空格) in Java and didn't find your desired class in the list, it means that it's not yet imported in current file. Pressing Ctrl+空格 once more to view all accessible classes.
view all accessible classes

suggest to convert Smart-type Completion result using toArray() call

Pressing the same shortcut after you have invoked Smart-type Completion when an array type is expected will search for collections with same component type and suggest to convert them using toArray() call.
suggest to convert Smart-type Completion result using toArray() call

sorting completion variants by relevance or alphabetically

You can switch between sorting completion variants by relevance or alphabetically by using an icon at the bottom right:
sorting completion variants by relevance or alphabetically

Postfix code completion

Postfix code completion is applied "from right to left" and lets you avoid backward caret jumps when coding. After the code fragment that you want to change, type a dot (.), optionally press Ctrl+J and select the desired option.
Postfix code completion

Scratch files

Scratch files allows you experiment and prototype right in the editor, without creating any project files.
To create a scratch file, press Ctrl+Alt+Shift+Insert, and then select its language.
Scratch files

changed a live template

If you've changed a live template, it becomes blue. If you want to return to the original text, right-click such a blue template, and choose Restore defaults on the context menu.

Add several cursors to your editor

在編輯器中添加多個光標

Add several cursors to your editor. To do that, press Ctrl twice and hold the key, and then press the arrow keys.
On Mac use Alt instead of Ctrl.
Add several cursors to your editor

Clone the cursor

Clone the cursor strictly upwards or downwards. To do that, press Ctrl+Shift+A, type Clone caret, and then choose the desired action.
Clone the cursor

view quick documentation when choosing a live template

When choosing a live template from a suggestion list, press Ctrl+Q to view quick documentation - to be sure you make a right choice:
view quick documentation when choosing a live template

launch the embedded local terminal using keyboard only

鍵盤啓動本地終端

Android Studio makes it possible to launch the embedded local terminal using keyboard only. Press Alt+F12, and see the terminal running.

Make your printoutsnice and informative with the help of keywords

Make your printouts (File | Print) nice and informative with the help of keywords.
For example, use $DATE$ and $TIME$ to specify the exact date and time of the printout.

show documentation for a lookup item

When in a Code Completion lookup, press Ctrl+Q to show documentation for a lookup item, including class constructors.
So doing, if a class has more than one constructor, the links are shown:
show documentation for a lookup item
Following a link shows documentation for the selected constructor.

Differences viewer

Have you noticed the buttons >><< marking differences in the Differences viewer?
You can simply apply differences between panes, by clicking one of these chevron buttons.
Keep the Ctrl key pressed, and the chevron buttons change to chevron button. Click one of these buttons to append contents of the current pane of the Differences viewer to the other pane.
If you keep Shift pressed, the chevrons turn into X. Click this button to revert changes.

code lens

Hover your mouse pointer over a warning, error stripe or just some section of source code on the scroll bar outside of the scroll box, and you will see a lens:
code lens

If the lens annoys you, get rid of it by clearing the check box on the context menu of the code analysis marker:
code lens

select multiple fragments in the "column mode"

"列模式"中選擇多個片斷:按Ctrl + Alt + Shift (Cmd+Alt+Shift on Mac)拖動鼠標便可。
感受用不用Ctrl沒區別

To select multiple fragments in the "column mode", keep Control+Alt+Shift(on Windows and Linux) or Cmd+Alt+Shift(on MAC), and drag your mouse cursor:
 select multiple fragments in the "column mode"

select multiple fragments of text

選擇多個文本片斷:按Alt + Shift 拖動鼠標便可。

You can easily select multiple fragments of text. To do that, it's enough to keep Alt+Shift and drag your mouse cursor:
select multiple fragments of text

select multiple words

選擇多個詞:按Alt + Shift雙擊鼠標左鍵 選擇詞便可。

To select multiple words, press Alt+Shift, place the caret at each word to be selected and double-click the left mouse button.
select multiple words

Show quick doc on mouse move

鼠標移動時顯示快速文檔:不須要顯式地調用快速文檔(Ctrl + Q),只將鼠標指針移動到所需的符號,快速文檔彈出窗口即自動顯示。
要啓用此功能,選中Settinigs | EditorShow quick doc on mouse move 複選框即。

You don't need to invoke quick documentation explicitly (Ctrl+Q) - if you just move your mouse pointer over the desired symbol, the quick documentation pop-up window will show automatically.
To enable this feature, select the check box Show quick doc on mouse move in the editor settings.

see all the available scratch files

查看全部可用的暫存文件:在項目工具窗口中選擇Scratches視圖

To see all the available scratch files, choose Scratches view in the Project tool window.
see all the available scratch files

copy rich text

富文本複製:確保選中了Settinigs | Editor | Genernal 頁面中的對應複選框便可。

Did you know that it's possible to copy rich text ?
Make sure that the check box Copy rich text by default in the General page of the Editor settings/preferences is selected:
copy rich text

generated automatically

生成自動聲明:當前文件中存在未聲明的命名空間,按兩次Ctrl+空格調用的代碼完成功能 能夠完成XML標記名稱。若是未聲明命名空間,則會自動生成聲明。

A special variant of the Code Completion feature invoked by pressing Ctrl+空格 twice allows you to complete XML tag names from namespaces not declared in the current file. If the namespace is not declared yet the declaration is generated automatically.
generated automatically

coding assistance for SQL

SQL代碼助手:能夠將SQL注入到字符串文字(Alt + Enter | Inject language or reference | <SQL dialect>),而後使用SQL編碼幫助。

You can inject SQL into a string literal (Alt+Enter | Inject language or reference | <SQL dialect>) and then use coding assistance for SQL.
coding assistance for SQL

優化引用

Ctrl + ALT + O 優化引用(Optimize Imports),能夠刪除無用的引用。

刪除無用資源

(Studio2.1+)Shift + Ctrl + Alt + I 彈出輸入框,輸入 Unused Resources 回車確認搜索後,點擊Remove All Unused Resources刪除全部無用資源。

Android Lint 還有其餘更強大的功能。


參考:

Idea快捷鍵(光標定位/切換/查找相關)
禁用系統的Ctrl+Alt+Left/Right(方向鍵)

相關文章
相關標籤/搜索