有用的 Eclipse 功能?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20529/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Useful Eclipse features?
提问by Adam Mika
I have been using Eclipse as an IDE for a short amount of time (about 3 months of full use) and almost every day I learn about some shortcut or feature that I had absolutely no idea about. For instance, just today I learned that Ctrl+3was the shortcut for a Quick Access window.
我将 Eclipse 作为 IDE 使用了很短的时间(大约 3 个月的完全使用),几乎每天我都会了解一些我完全不知道的快捷方式或功能。例如,就在今天,我了解到Ctrl+3是快速访问窗口的快捷方式。
I was wondering what your most useful/favorite Eclipse features are. With the IDE being so big, it would be helpful to learn about the more commonly used parts of the program.
我想知道您最有用/最喜欢的 Eclipse 功能是什么。由于 IDE 如此之大,了解程序中更常用的部分会很有帮助。
回答by Cheekysoft
My most commonly used features are
我最常用的功能是
ctrl+1quick-fix / spell-checker
ctrl+1快速修复/拼写检查
opening files
打开文件
- ctrl+shift+tload class file by classname
- ctrl+shift+rload any file by filename
- ctrl+ shift+t按类名加载类文件
- ctrl+ shift+r按文件名加载任何文件
matches are made on the start of the class/filename. start your search pattern with a * to search anywhere within the filename/classname.
在类/文件名的开头进行匹配。以 * 开始搜索模式以搜索文件名/类名中的任何位置。
Formatting
格式化
- ctrl+shift+fFormat source file (set up your formatting style in Window | preferences | java | code style | formatter)
- ctrl+shift+oOrganise imports
- ctrl+ shift+f格式化源文件(在 Window | 首选项 | java | 代码样式 | 格式化程序中设置您的格式样式)
- ctrl+ shift+o组织进口
Generated code
生成的代码
- alt+s,rto generate getters and setters
- alt+s,vto insert method signatures for overidden methods from superclass or interface
- alt+ s,r生成 getter 和 setter
- alt+ s,v为来自超类或接口的覆盖方法插入方法签名
Refactorings
重构
- alt+shift+lExtract text-selection as local variable (really handy in that it determines and inserts the type for you.
- alt+shift+mExtract text-selection as a method
- alt+shift+iinline selected method
- alt+ shift+ 将l文本选择提取为局部变量(非常方便,因为它可以为您确定并插入类型。
- alt+ shift+m提取文本选择作为一种方法
- alt+ shift+i内嵌选择的方法
Running and debugging.
运行和调试。
alt+shift+xis a really handy prefix to run stuff in your current file.
alt+ shift+x是一个非常方便的前缀,可以在当前文件中运行内容。
- alt+shift+x, trun unit tests in current file
- alt+shift+x, jrun main in current file
- alt+shift+x, rrun on server
- alt+ shift+ x,t在当前文件运行单元测试
- alt+ shift+ x,j运行在当前文件主
- alt+ shift+ x,r在服务器上运行
There are more. The options are shown to you in the lower-right popup after hitting alt+shift+x.
还有更多。点击alt+ shift+后,选项会显示在右下角的弹出窗口中x。
alt+shift+xcan be switched for alt+shift+din all the above examples to run in the debugger.
alt+ shift+x可以切换为alt+ shift+d在所有上述实施例中调试器中运行。
Validation
验证
As of the recent Ganymede release, you can now switch of validation in specified files and folders. I've been waiting for this feature for ages.
从最近的 Ganymede 版本开始,您现在可以在指定的文件和文件夹中切换验证。我等这个功能很久了。
- Go to Project | Properties | Validation
- click on the ... button in the settings column of the validator you want to shut up
- Add a rule to the exclude group
- 转到项目 | 属性 | 验证
- 单击要关闭的验证器设置列中的 ... 按钮
- 向排除组添加规则
code navigation
代码导航
- hold down ctrlto make all variables, methods and classnames hyperlinks to their definitions.
- alt+leftto navigate back to where you clicked ctrl
- alt+rightto go "forwards" again
- 按住ctrl使所有变量、方法和类名超链接到它们的定义。
- alt+left导航回您单击的位置ctrl
- alt+right再次“前进”
回答by David Koelle
This is cool: If someone has emailed you a stack trace, you can copy and paste the stack trace into Eclipse's Console window. You can then click on class names in the stack trace as if your own code had generated it.
这很酷:如果有人通过电子邮件向您发送了堆栈跟踪,您可以将堆栈跟踪复制并粘贴到 Eclipse 的控制台窗口中。然后,您可以单击堆栈跟踪中的类名,就好像您自己的代码已生成它一样。
回答by serg10
In terms of actual features, rather than shortcuts, I strongly recommend taking a look at Mylyn.
就实际功能而言,而不是快捷方式,我强烈建议您查看Mylyn。
It essentially skins Eclipse with a task focussed view. It tracks the files you touch when working on a task, and focusses many aspects of the UI onto the resources that it decides are relevant to the job in hand. Eclipse can be somewhat busy to look at, especially with a big multi module project, and Mylyn helps cut through the cruft. The connectivity to issue tracking software and source control repositories is also excellent.
它本质上为 Eclipse 提供了一个以任务为中心的视图。它跟踪您在处理任务时接触的文件,并将 UI 的许多方面集中在它认为与手头工作相关的资源上。Eclipse 可能有点忙,尤其是对于一个大型的多模块项目,Mylyn 帮助解决了繁琐的问题。与问题跟踪软件和源代码控制存储库的连接也非常出色。
In my experience, it polarises opinion amongst those who try working with it, which is probably a sign that it is offering something interesting... Don't mean to sound like a fanboy - it is definitely worth a look though.
根据我的经验,它在尝试使用它的人中引起了两极分化,这可能表明它提供了一些有趣的东西......不要故意听起来像个狂热分子 - 不过它绝对值得一看。
回答by N8g
Ctrl-Alt(up/down) Copy selected line(s) above or below current line.
Alt(up/down) Move current (or multiple selected) lines up or down
Ctrl-Shift-RBring up the resource window, start typing to find class/resource
Ctrl-OBring up all methods and fields for the current class. Hitting it again will bring up all methods and fields for current class and super classes.
Ctrl-/or Ctrl-Alt-CComment single or multiple lines with //
Ctrl-Shift-/Comment selected lines with /* */
Ctrl-.Take you to the next error or warning line
Ctrl- Alt( up/ down) 在当前行的上方或下方复制选定的行。
Alt( up/ down) 向上或向下移动当前(或多个选定)行
Ctrl- Shift- 调R出资源窗口,开始键入以查找类/资源
Ctrl- 调O出当前类的所有方法和字段。再次点击它会调出当前类和超类的所有方法和字段。
Ctrl-/或Ctrl- Alt-C用 // 注释单行或多行
Ctrl- Shift-/用 /* */ 注释所选行
Ctrl-.带您到下一个错误或警告行
回答by Romain Linsolas
A shortcut that I use everyday is Ctrl+K. In your editor (not only Java file), simply select a text (like a variable, a function, etc.), and then use this shortcut to go to the next occurrence of this text in the current editor. It's faster than using the Ctrl+Fshortcut...
我每天使用的快捷方式是Ctrl+ K。在您的编辑器(不仅是 Java 文件)中,只需选择一个文本(如变量、函数等),然后使用此快捷方式转到当前编辑器中该文本的下一次出现处。它比使用Ctrl+F快捷方式更快......
Note also that you can use Ctrl+Shift+Kto search backwards.
还需要注意的是,你可以使用Ctrl+ Shift+K向后搜索。
回答by Alex
CTRL+PAGE DOWN/ CTRL+PAGE UPto switch between opened editors
CTRL+ PAGE DOWN/ CTRL+PAGE UP在打开的编辑器之间切换
CTRL+Eto also switch between opened editors (allows to type the name)
CTRL+E还可以在打开的编辑器之间切换(允许输入名称)
CTRL+Ois extremely important for me. You don't longer need the Outline View then (you can close it which will give you more space). Then, you can type a method name or just the beginning of it and you quickly can get to it. I also use it to inspect what stuff is available. For example: CTRL+Oand then type get ... now I see all getters.
CTRL+O对我来说非常重要。您不再需要大纲视图(您可以关闭它,这将为您提供更多空间)。然后,您可以键入一个方法名称或仅键入它的开头,然后您就可以快速找到它。我还用它来检查可用的东西。例如:CTRL+O然后输入 get ... 现在我看到了所有的 getter。
F3while an element is selected in the code: brings you to its definition or it's source. e.g. used on a method call it brings you into the source code of that method.
F3在代码中选择一个元素时:将您带到它的定义或它的来源。例如,用于方法调用时,它会将您带入该方法的源代码。
CTRL+Mto maximize the current window
CTRL+M最大化当前窗口
As already said, CTRL+3is extremely good. It basically allows you to use Eclipse completely without a mouse. Just type CTRL+3and then package explorer for example.
如前所述,CTRL+3非常好。它基本上允许您在没有鼠标的情况下完全使用 Eclipse。例如,只需键入CTRL+3然后打包资源管理器。
CTRL+F8cycle trough perspectives
CTRL+F8周期低谷观点
CTRL+Lallows to type a line number and brings you directly to that line.
CTRL+L允许输入行号并直接将您带到该行。
CTRL+SHIFT+Gsearches for all references to the selected element in the workspace.
CTRL+ SHIFT+G在工作区中搜索对所选元素的所有引用。
And not a shortcut: In the project settings under Java Editor you can find Save Actions. This allows you to set up the project so that the code is automatically cleaned up and formatted when you save a file. That's very good it safes you from constantly pressing CTRL+Oand CTRL+F.
而不是快捷方式:在 Java 编辑器下的项目设置中,您可以找到保存操作。这允许您设置项目,以便在保存文件时自动清理和格式化代码。这非常好,它可以让您免于不断按下CTRL+O和CTRL+ F。
回答by Charles Ma
Eclipse auto refresh isn't on by default so if you make changes to a file outside of eclipse, the change won't be reflected in your build. this is very annoying if you just did an svn/git update/rebase and things aren't working the way they're supposed to.
Eclipse 自动刷新在默认情况下不启用,因此如果您在 Eclipse 之外对文件进行更改,则更改不会反映在您的构建中。如果你只是做了一个 svn/git update/rebase 并且事情没有按照他们应该的方式工作,这会很烦人。
Turn it on in windows->preferences->workspace and tick Refresh Automatically.
在 windows->preferences->workspace 中打开它并勾选自动刷新。
回答by serg
Local History
地方历史
It's a great feature. Eclipse has its own mini-CVS for all files in a project. If you want to revert some change you made, or even restore deleted file - you can right click on the project and select "Restore from Local History".
这是一个很棒的功能。Eclipse 对项目中的所有文件都有自己的迷你 CVS。如果您想恢复您所做的某些更改,甚至恢复已删除的文件 - 您可以右键单击该项目并选择“从本地历史记录中恢复”。
Just saved my ass *tears of joy*
刚刚救了我的屁股*喜悦的泪水*
回答by karlphillip
CTRL+Shift+Pto jump to the matching bracket/parenthesis.
CTRL+ Shift+P到跳转到匹配支架/括号。
回答by David Koelle
- Ctrl-shift-T, but only type the initial characters (and even a few more) of the class you're looking for. For example, you can type "NetLi" to find NetworkListener
- In the Search window, Ctrl-.takes you to the first leaf of a tree branch
- Alt-/is Word Completion. Slightly different from Ctrl-space
- Ctrl- shift- T,但只输入您要查找的类的初始字符(甚至更多)。例如,您可以输入“NetLi”来查找 NetworkListener
- 在搜索窗口中,Ctrl-.带您到树枝的第一片叶子
- Alt-/是单词完成。与Ctrl——略有不同space