大家覺得有用的話就存下來吧,如果不熟悉的話經常去live pemplate進行查詢有點麻煩,用熟悉了後就會好很多啦
Android studio 默認的是按Tab 自動生成代碼塊的,用戶可以自己在setting-->Live Templates裏面進行設置expand style
////輸出打印
Groovy(常規部分)---->
serr --->System.err.println("example")
souf --->printf "example"
sout --->println "example"
soutm --->System.out.println("MainActivity.onCreate");//當前類的當前方法名
soutp --->System.out.println("savedInstanceState = [" + savedInstanceState + "]");//這個好,可以打印出當前方法的所有參數列表及其值
soutv --->System.out.println("params",params);//即 你可以輸出打印一個變量值
//(常規的代碼塊兒)
Iteractions--->//快速生成代碼塊兒
fori --->for (int i = 0; i < ; i++) {}
itar --->for (int i = 0; i < Array.length; i++) { int i1 = Array[i];}//遍歷數組
itco --->for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) {
Object next = iterator.next();
}//這個是遍歷一個容器變量的,直接讓容器返回一個iterator進行遍歷
iten --->while (枚舉類.hasMoreElements()) { Object nextElement = 枚舉類.nextElement(); }//enumeration 是一個枚舉類接口來着。遍歷枚舉內容
iter --->for (int i : FOCUSED_STATE_SET) {...}//遍歷選中狀態下的set
itit --->while (iterator.hasNext()) { Object next = iterator.next(); }//獲取到了迭代器對象後,對迭代器進行遍歷操作
itli --->for (int i = 0; i < list.size(); i++) { Object o = list.get(i); }//遍歷list對象裏面的內容
ritar --->for (int i = Array.length - 1; i >= 0; i--) { int i1 = FOCUSED_STATE_SET[i]; }//倒敘遍歷數組
//其他的(綜合)
geti --->public static MainActivity getInstance() { return ; }//獲取到當前的實例 的代碼模板
ifn --->if (某變量 == null) {....}//生成if null代碼塊兒
inn --->if (某變量 != null) {....}//生成if not null代碼塊兒
inst --->if ($EXPR$ instanceof $TYPE$) { $TYPE$ $VAR1$ = ($TYPE$)$EXPR$; $END$ }//判斷某變量是不是某個類的實例對象
lazy --->if (savedInstanceState == null) { savedInstanceState = new Bundle(); }//執行延遲初始化,就是對象直到用的時候才進行初始化操作
mn --->var1 = Math.min(var2,var3);//得到比較兩個變量值小的代碼塊
mx --->var1 = Math.max(var2,var3);//得到比較兩個變量值大的代碼塊
psvm --->public static void main(String[] args){ 。。。。 }//生成一個main()函數的代碼塊
toar --->something.toArray(new collection[collection.size()])//這個是生成一個代碼塊用於把collection的對象存儲到一個數組裏面去.實用!
//普通的代碼(修飾符部分的)
psf --->public static final
psfi --->public static final int
psfs --->public static final String
St --->String
thr --->throw new
To find any action inside the IDE use
Find Action Ctrl+Shift+A/ A 查找快捷鍵,action快捷入口的快捷鍵
Editing 編輯
Ctrl + Space | Basic code completion (the name of any class,method or variable) | 基本的代碼補全 |
Ctrl + Shift + Space | Smart code completion (filters the list of methodsand variables by expected type) | 智能代碼補全 |
Ctrl + Shift + Enter | Complete statement | 補全當前語句 |
Ctrl + P | Parameter info (within method call arguments) | 顯示函數的參數信息 |
Ctrl + Q | Quick documentation lookup | 快速文檔查找 |
Shift + F1 | External Doc | 外部文檔 |
Ctrl + mouse over code | Brief Info | 簡要信息顯示 |
Ctrl + F1 | Show descriptions of error or warning at caret | 顯示錯誤或警告的說明 |
Alt + Insert | Generate code... (Getters, Setters, Constructors,hashCode/equals, toString) | 生成(Getters, Setters, Constructors,hashCode/equals, toString)代碼 |
Ctrl + O | Override methods | 重寫方法 |
Ctrl + I | Implement methods | 實現方法 |
Ctrl + Alt + T | Surround with… (if..else, try..catch, for,synchronized, etc.) | 用if..else, try..catch, for,synchronized等環繞代碼塊 |
Ctrl + / | Comment/uncomment with line comment | 註釋/取消註釋代碼行 |
Ctrl + Shift + / | Comment/uncomment with block comment | 註釋/取消註釋代碼塊 |
Ctrl + W | Select successively increasing code blocks | 依次選擇更多的代碼塊 |
Ctrl + Shift + W | Decrease current selection to previous state | 依次減少選擇的代碼塊 |
Alt + Q | Context info |
|
Alt + Enter | Show intention actions and quick-fixes | 顯示意圖行動和快速修復 |
Ctrl + Alt + L | Reformat code | 重新格式化代碼 |
Ctrl + Alt + O | Optimize imports | 優化導入的import |
Ctrl + Alt + I | Auto-indent line(s) | 自動縮進行 |
Tab / Shift + Tab | Indent/unindent selected lines | 縮進/取消縮進 |
/Ctrl + X or Shift + Delete | Cut current line or selected block to clipboard | 剪切當前行或者選中的代碼段到剪切板 |
Ctrl + C or Ctrl + Insert | Copy current line or selected block to clipboard | 複製當前行或者選中的代碼段到剪貼板 |
Ctrl + V or Shift + Insert | Paste from clipboard | 從剪切板粘貼 |
Ctrl + Shift + V | Paste from recent buffers... | 粘貼最近複製的內容 |
Ctrl + D | Duplicate current line or selected block | 複製當前行或選中的代碼 |
Ctrl + Y | Delete line at caret | 刪除行 |
Ctrl + Shift + J | Smart line join | 智能合併行 |
Ctrl + Enter | Smart line split | 智能分割行 |
Shift + Enter | Start new line | 新建一行 |
Ctrl + Shift + U | Toggle case for word at caret or selected block | 將選中代碼塊轉爲小寫 |
Ctrl + Shift + ] / [ | Select till code block end/start | 向前/向後選中代碼段 |
Ctrl + Delete | Delete to word end | 向後刪除一個單詞 |
Ctrl + Backspace | Delete to word start | 向前刪除一個單詞 |
Ctrl + NumPad+/- | Expand/collapse code block | 展開/摺疊代碼段 |
Ctrl + Shift + NumPad+ | Expand all | 全部展開 |
Ctrl + Shift + NumPad- | Collapse all | 全部摺疊 |
Ctrl + F4 | Close active editor tab | 關閉當前標籤 |
Search/Replace 查找/替換
Double Shift | Search everywhere | 搜索任何地方的任何東西 |
Ctrl + F | Find | 查找 |
F3 | Find next | 查找下一個 |
Shift + F3 | Find previous | 查找上一個 |
Ctrl + R | Replace | 替換 |
Ctrl + Shift + F | Find in path | 在路徑中查找 |
Ctrl + Shift + R | Replace in path | 在路徑中替換 |
Ctrl + Shift + S | Search structurally (Ultimate Edition only) | 查找機構(商業版有效) |
Ctrl + Shift + M | Replace structurally (Ultimate Edition only) | 替換結構(商業版有效) |
Usage Search 查找使用
Alt + F7 / Ctrl + F7 | Find usages / Find usages in file | 查找使用 |
Ctrl + Shift + F7 | Highlight usages in file | 在文件中高亮被使用處 |
Ctrl + Alt + F7 | Show usages | 顯示使用 |
Compile and Run 編譯和運行
Ctrl + F9 | Make project (compile modifed and dependent) | 編譯項目 |
Ctrl + Shift + F9 | Compile selected file, package or module | 編譯選中的文件、包或者木塊 |
Alt + Shift + F10 | Select configuration and run | 選擇配置然後運行 |
Alt + Shift + F9 | Select configuration and debug | 選擇哦誒之然後調試 |
Shift + F10 | Run | 運行 |
Shift + F9 | Debug | 調試 |
Ctrl + Shift + F10 | Run context configuration from editor |
|
Debugging 調試
F8 | Step over | 跳過函數執行 |
F7 | Step into | 單步執行 |
Shift + F7 | Smart step into | 智能但不執行 |
Shift + F8 | Step out | 跳出函數執行 |
Alt + F9 | Run to cursor | 運行到光標處 |
Alt + F8 | Evaluate expression |
|
F9 | Resume program | 繼續執行 |
Ctrl + F8 | Toggle breakpoint | 切換斷點 |
Ctrl + Shift + F8 | View breakpoints | 查看斷點 |
Navigation 導航
Ctrl + N | Go to class | 查找/跳到類 |
Ctrl + Shift + N | Go to file | 查找文件 |
Ctrl + Alt + Shift + N | Go to symbol | 查找符號 |
Alt + Right/Left | Go to next/previous editor tab |
|
F12 | Go back to previous tool window |
|
Esc | Go to editor (from tool window) |
|
Shift + Esc | Hide active or last active window |
|
Ctrl + Shift + F4 | Close active run/messages/find/... tab |
|
Ctrl + G | Go to line |
|
Ctrl + E | Recent files popup | 最近打開的文件 |
Ctrl + Alt + Left/Right | Navigate back/forward | 回到上一步/下一步編輯的地方 |
Ctrl + Shift + Backspace | Navigate to last edit location | 回到最後編輯的地方 |
Alt + F1 | Select current file or symbol in any view | 在任意視圖中選中當前文件或者符號 |
Ctrl + B or Ctrl + Click | Go to declaration | 到變量定義處 |
Ctrl + Alt + B | Go to implementation(s) | 到方法的實現處 |
Ctrl + Shift + I | Open quick definition lookup | 打開定義快速查找 |
Ctrl + Shift + B | Go to type declaration | 跳轉到方法定義處 |
Ctrl + U | Go to super-method/super-class | 跳轉到父方法/父類 |
Alt + Up/Down | Go to previous/next method | 跳轉到上一個/下一個方法 |
Ctrl + ] / [ | Move to code block end/start | 跳到代碼段的開始/結尾 |
Ctrl + F12 | File structure popup | 彈出文件結構視圖 |
Ctrl + H | Type hierarchy | 類型的層次結構? |
Ctrl + Shift + H | Method hierarchy | 方法的層次結構? |
Ctrl + Alt + H | Call hierarchy | 調用的層次結構(查找方法/符號的調用方) |
F2 / Shift + F2 | Next/previous highlighted error | 下一個(上一個)高亮的錯誤 |
F4 / Ctrl + Enter | Edit source / View source | 編輯/查看文件源碼 |
Alt + Home | Show navigation bar | 顯示導航欄 |
F11 | Toggle bookmark | 增加書籤 |
Ctrl + F11 | Toggle bookmark with mnemonic | 增加帶符號的書籤 |
Ctrl + #[0-9] | Go to numbered bookmark | 跳到標記數字的書籤 |
Shift + F11 | Show bookmarks | 顯示書籤 |
Refactoring 代碼重構
F5 | Copy | 複製 |
F6 | Move | 移動 |
Alt + Delete | Safe Delete | 安全刪除 |
Shift + F6 | Rename | 重命名變量/方法名 |
Ctrl + F6 | Change Signature | 改變 |
Ctrl + Alt + N | Inline |
|
Ctrl + Alt + M | Extract Method |
|
Ctrl + Alt + V | Extract Variable |
|
Ctrl + Alt + F | Extract Field |
|
Ctrl + Alt + C | Extract Constant |
|
Ctrl + Alt + P | Extract Parameter |
|
VCS/Local History 版本管理/本地歷史
Ctrl + K | Commit project to VCS |
|
Ctrl + T | Update project from VCS |
|
Alt + Shift + C | View recent changes | 查看最近更改的內容 |
Alt + BackQuote (`) | ‘VCS’ quick popup |
|
Live Templates 動態模板
Ctrl + Alt + J | Surround with Live Template | 環繞的動態模板 |
Ctrl + J | Insert Live Template | 插入動態模板 |
iter | Iteration according to Java SDK 1.5 style |
|
inst | Check object type with instanceof and downcast it |
|
itco | Iterate elements of java.util.Collection |
|
itit | Iterate elements of java.util.Iterator |
|
itli | Iterate elements of java.util.List |
|
psf | public static final |
|
thr | throw new |
|
General 通用
Alt + #[0-9] | Open corresponding tool window | 打開相應的工具窗口 |
Ctrl + S | Save all | 保存 |
Ctrl + Alt + Y | Synchronize | 同步 |
Ctrl + Shift + F12 | Toggle maximizing editor | 最大化編輯窗口 |
Alt + Shift + F | Add to Favorites | 添加到Favorites |
Alt + Shift + I | Inspect current file with current profile |
|
Ctrl + BackQuote (`) | Quick switch current scheme |
|
Ctrl + Alt + S | Open Settings dialog | 打開設置窗口 |
Ctrl + Alt + Shift + S |
Open Project Structure dialog | 打開項目結構窗口 |
Ctrl + Shift + A | Find Action | 查找快捷鍵 |
Ctrl + Tab | Switch between tabs and tool window |
在選項卡和工具窗口之間切換 |