好的,这可能是一个简单的问题,但每个人使用这些工具的方式都不同。那么,有哪些在这个集成开发环境中最好的时间节省工具呢?
汤姆
目前还没有提到最好的方法。点击类或方法名称,然后按Ctrl+T键。
您将获得快速类型层次结构。对于类名,您将看到整个类层次结构。对于方法名,您将获得显示超类和子类的层次结构,其中该方法的实现与抽象提及或不提及该方法的类有所区别。
当您处于抽象方法声明位置并且想快速查看其实现位置时,此功能非常重要。
F3一直是我最喜欢的快捷键,可以打开所选项的定义。
Ctrl+Shift+R有一个有趣的功能,在搜索时只需要使用类名中的大写驼峰字母(比如输入CWAR将显示ClassWithAReallyLongName的结果)。
Alt+Shift+W > Package Explorer在浏览大型项目时可以更轻松地浏览。
Eclipse允许你根据异常发生的位置设置断点。
你可以通过调试窗口中的"j!" alt text http://help.eclipse.org/stable/topic/org.eclipse.jdt.doc.user/images/org.eclipse.jdt.debug.ui/elcl16/exc_catch.png图标访问此选项。
alt text http://blogs.bytecode.com.au/glen/2007/04/06/images/2007/AddExceptionWindow.png
官方帮助主题"添加Java异常断点"对此进行了更多说明。
RuntimeException
配置了异常断点以在子类上挂起,则也会因NullPointerException
而触发。一种非键盘快捷方式是在“团队”->“同步”视图中使用提交集来组织您的更改,然后再进行提交。
将一个变更集设置为默认值,您所做的所有文件更改都将放入该集合中,这样就可以很容易地查看您在修复特定缺陷/功能和测试等过程中所做的更改以及其他更改。
CTRL+SPACE,无论何时何地都可以使用。
生成getter和setter方法。
使用字段创建构造函数
提取方法...
重构->重命名
CTRL+O快速查看大纲。CTRL+O+CTRL+O查看继承的大纲。
F4显示类型层次结构
打开调用层次结构以显示方法被调用的位置。
CTRL+SHIFT+T打开Java类型
CTRL+SHIFT+R打开任何资源。
ALT +左或右向前或向后浏览文档中的编辑位置(轻松导航)
如果您知道要执行很多方法,请覆盖/实现方法(否则,对于一次选择,CTRL+SPACE更好)。
重构->提取接口
重构->上移
重构->下移
CTRL+SHIFT+O组织导入(当输入Map等一般类名时,按CTRL+SPACE,然后选择适当的类将直接为您导入它)。
CTRL+SHIFT+F格式化(尽管Eclipse内置的格式化器对长行代码有点愚蠢)
编辑:哦,是的,还有一些调试:
F5:逐步进入(显示细节!)
F6:步骤(跳过这一部分...)
F7:跳出(我认为我关心这个方法,但事实证明我不关心,让我走吧!)
F8:恢复(直到达到下一个断点)
CTRL+SHIFT+I:检查表达式。CTRL+SHIFT+I+CTRL+SHIFT+I:在检查的表达式上创建监视表达式。
条件断点:右键单击断点,您可以设置触发程序执行停止的条件(此处提供Ctrl+Space的上下文辅助!)
F11 - 调试最后启动(应用程序)
CTRL+F11 - 运行最后启动(应用程序)
Ctrl+Alt+UP或Ctrl+Alt+DOWN可复制多行内容。
按下Ctrl+Alt+H可以获取方法的调用层次结构,快速查看其被哪些地方调用。
使用 Alt + Shift + R 快捷键进行重构和重命名。
以下是我收集的Eclipse 3最有用的键盘快捷键:
Eclipse 3 Favorite Keyboard Shortcuts.
by -=MaGGuS=-
Navigate:
• Ctrl + Shift + L – Shows useful keyboard shortcuts in popup window
• Ctrl + H – Search.
• Ctrl + K – Goes to next search match in a single file. Shift + Ctrl + K – goes to previous match.
• F3 - Goes to ‘declaration’ of something. Same as Ctrl + Click.
• Ctrl + Shift + G - Use this on a method name or variable. It will search for references in the code (all the code) to that item.
• Ctrl + O – Shows outline view of the current class or interface.
• Ctrl + T – Shows class hierarchy of the current class or interface. F4 – shows the same in separate tab.
• Ctrl + Shift + T - Open Type. Search for any type globally in the workspace.
• Ctrl + Shift + R – Open Resource. Search for any file inside workspace.
• Ctrl + J – Incremental search. Similar to the search in firefox. It shows you results as you type. Shift + Ctrl +J - Reverse incremental search.
• Ctrl + Q – Goes to the last edit location.
• Ctrl + Left|Right – Go Back/Forward in history.
• Ctrl + L – Go to line number.
• Ctrl + E – This will give you a list of all the source code windows that are currently open. You can arrow up or down on the items to go to a tab.
• Ctrl +PgUp|PgDown – Cycles through editor tabs.
• Ctrl + Shift + Up|Down - Bounces you up and down through the methods in the source code.
• Ctrl + F7 – Switches between panes (views).
• Ctrl + ,|. – Go to the previous/next error. Great in combination with Ctrl + 1.
• Ctrl + 1 on an error – Brings up suggestions for fixing the error. The suggestions can be clicked.
• Ctrl + F4 – Close one source window.
Edit:
• Ctrl + Space – Auto-completion.
• Ctrl + / – Toggle comment selected lines.
• Ctrl + Shift + /|\ – Block comment/uncomment selected lines.
• Ctrl + Shift + F – Quickly ‘formats’ your java code based on your preferences set up under Window –> Preferences.
• Ctrl + I – Correct indentations.
• Alt + Up|Down – move the highlighted code up/down one line. If nothing is selected, selects the current line.
• Ctrl + D – Delete row.
• Alt + Shift + Up|Down|Left|Right – select increasing semantic units.
• Ctrl + Shift + O – Organize Imports.
• Alt + Shift + S – Brings up “Source” menu.
o Shift + Alt + S, R – Generate getter/setter.
o Shift + Alt + S, O – Generate constructor using fields.
o Shift + Alt + S, C – Generate constructor from superclass.
• Alt + Shift + T – Brings up “Refactor” menu.
• Alt + Shift + J – Insert javadoc comment.
• F2 – Display javadoc popup for current item. Shift + F2 – Display javadoc in external browser.
Run/Debug:
• F11 / Ctrl + F11 – Execute/debug.
• Ctrl + Shift +B – Toggle breakpoint.
• When paused: F5 – Step into, F6 – Step over, F7 – Step out, F8 – Resume.
• Ctrl + F2 – Terminate.
EOF
并不是很难懂,但我认为这是最好的技巧。
假设默认设置(且您没有添加新片段)
高亮(或选择)文本(字符串或变量)…按Ctrl+Space。 然后按End+Enter键, 将触发“sysout”片段,它将所选内容包裹在其参数中。
例如:
"hello world!"
becomes
System.out.println("hello world!");
我非常喜欢它,以至于我已经为Android的Toast和Log.i()实现了类似的代码片段 在手动调试期间节省了大量时间....