做Java開發,首選IDE當然是Eclipse,其提供的快捷鍵則充當了程式員的瑞士軍刀。遠離滑鼠,多用用Hot-Key,通過保持專注來提高編碼效率。在stackoverflow網站上有一篇主題帖分享了大家最喜愛的Eclipse快捷鍵What is your favorite hot-key in Eclipse?
下面對這些快捷鍵做一番整理。 快捷鍵一覽表:
- Ctrl+Shift+L - Gives a quick reference of Eclipse Hotkeys (at least in Galileo) (不記得下面的這些快捷鍵,應多使用該方法調出快捷鍵一覽表)
編輯相關:
- Alt+/ - auto complete. Completes everything. (補齊方法名、變量名、類名)
- Ctrl+/ - comment/uncomment selected lines (添加注釋)
- Alt+Shift+R - rename selection (重命名)
- Ctrl+Shift+F to format code (編碼格式化)
- Ctrl+M - Maximize Page (最大化頁面)
- Ctrl+Q - return to last edit location (回到上一次編輯位置)
錯誤檢查:
- Ctrl+1 - suggestions and quick fixes. (提供快速的除錯建議)
- Ctrl+Shift+O - organise imports (removes unused imports, adds missing imports, sorts imports) (快速導入依賴的包)
- Ctrl+Shift+M - Add Import. Love to see those red underlines disappear. (感覺Ctrl+Shift+O更好用)
源碼閱讀:
- F3 - Open definition: jumps to the definition of the class, method, variable, even if it is in remote places (such as classes in the JDK itself) (跳到類、方法等的定義處)
- F4 - Open Type Hierarchy (打開類的繼承結構圖)
- Ctrl+O (not zero, but the vocal) - Shows the outline of the document (顯示Outline視圖)
- Ctrl+T: Once will give you supertypes, twice should give you interfaces as well. (點一次顯示超類,點兩次顯示接口)
- Ctrl+F3 - (once - Show class methods and variables) (點選一次,顯示該類的方法和變量)
- Ctrl+F3 - (Hit this hot key combo twice to see inherited members and methods) (點選兩次,顯示繼承的方法和變量)
導航相關:
- Ctrl + Shift + T - find as you type for Java classes in your projects (當你隻記得類的首字母時,可以快速查找某一個類)
- Ctrl+Shift+R - find as you type for all resources in your projects (通過首字母快速查找所有的資源:圖檔、java檔案等)
- Alt+Left - step backwards through editing history (回到上一次編輯曆史)
- Alt+Right - step forwards through editing history (回到下一次編輯曆史)
編譯運作相關:
- Ctrl +F11 - run again (運作)
- F11 - run again in debug mode (調試模式運作)