做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 (调试模式运行)