在 Eclipse 中使用快速修复的更快方法(键盘快捷键?)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1536869/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:58:33  来源:igfitidea点击:

Faster way (keyboard shortcuts?) to use quick fixes in Eclipse?

eclipse

提问by Hanno Fietz

I often use the Eclipse feature (Galileo) of suggested error corrections to automatically create code stubs or to refactor things. For example, I would write a method that calls other methods which don't exist yet, then move the mouse over the error message and click on "create method". Or, change thisto the class name and choose "add staticmodifier" from the quick fixes.

我经常使用 Eclipse 特性 (Galileo) 的建议纠错功能来自动创建代码存根或重构事物。例如,我会编写一个调用其他尚不存在的方法的方法,然后将鼠标移到错误消息上并单击“创建方法”。或者,更改this为类名并static从快速修复中选择“添加修饰符”。

I think this is very convenient because it lets me stay in one place in my code and sort of "remotely" wire up what's not currently visible on my screen. What I think is annoying though, is that I have to leave the keyboard, hover my mouse over the error symbol, wait for the tooltip to pop up, and click on the option (doing that, I sometimes move the mouse a little over the edge and the tooltip goes away again - very annoying).

我认为这非常方便,因为它让我可以在我的代码中停留在一个地方,并且可以“远程”连接屏幕上当前不可见的内容。但我认为很烦人的是,我必须离开键盘,将鼠标悬停在错误符号上,等待工具提示弹出,然后单击选项(这样做,我有时将鼠标移到边缘和工具提示再次消失 - 非常烦人)。

Am I missing a faster method here? I can't seem to find a keyboard shortcut, but then I have overlooked stuff from the huge preference dialog before.

我在这里错过了更快的方法吗?我似乎找不到键盘快捷键,但是我之前忽略了巨大的首选项对话框中的内容。

回答by VonC

Ctrl+1: Quick Fix.
(Cmd+1on Mac)

Ctrl+ 1:快速修复。
( Cmd+1在 Mac 上)

Just put your cursor on the part you suspect you can perform an action (correction, refactoring, ...) and hit the Quick Fixshortcut. The same popup will be displayed, and you can select the right option with the up and down keys.

只需将光标放在您怀疑可以执行操作(更正、重构等)的部分上,然后点击Quick Fix快捷方式。将显示相同的弹出窗口,您可以使用向上和向下键选择正确的选项。

Europa spell

欧罗巴咒语

That, combined with Ctrl+3(Quick Access) gives you most of eclipse features at your fingertips ;)

结合Ctrl+ 3( Quick Access) 为您提供大部分 Eclipse 功能触手可及;)

See also:

也可以看看:

回答by Janac Meena

After using ctrl+1like mentioned in the top answer, press ctrl+ enterto apply the selected fix all to problems of the same category.

使用顶部答案中提到的ctrl+后1,按ctrl+enter将选定的修复全部应用于同一类别的问题。

回答by costarec

In general, keyboard shortcuts in IDEs (and code tools in general) are coming from a user principle that holds that the more your hands/fingers can remain poised over the keyboard (as in the f-j centered "touch typist" position), the more productive you can become. This is probably why the use of the number keypad is not encouraged, or other keys, less common to the most basic layout keyboard, are not used. Many hold that useful keyboard shortcuts should be easily reachable from this position.

一般来说,IDE 中的键盘快捷键(以及一般的代码工具)来自一个用户原则,即您的手/手指在键盘上保持平衡的次数越多(如在 fj 居中的“触摸打字员”位置),你可以变得富有成效。这可能就是为什么不鼓励使用数字小键盘的原因,或者不使用对最基本的布局键盘不太常见的其他键。许多人认为,从这个位置应该可以轻松访问有用的键盘快捷键。

One thing I will say about eclipse keyboard shortcuts is that if you use a popular Windows presentation utility called Zoom-it, you need to turn that off when using eclipse. There are several show-stopper conflicts between the two, such as Ctrl-1 and Ctrl-3.

关于 eclipse 键盘快捷键,我要说的一件事是,如果您使用名为 Zoom-it 的流行 Windows 演示实用程序,则需要在使用 eclipse 时将其关闭。两者之间有几个显示停止器冲突,例如 Ctrl-1 和 Ctrl-3。

回答by Godsmith

As an additional tip, a specific type of quick fix I use all the time has a dedicated shortcut:

作为额外的提示,我一直使用的特定类型的快速修复有一个专用的快捷方式:

Alt+Shift+J: Add Javadoc comment stub for current method.

Alt+ Shift+ J: 为当前方法添加 Javadoc 注释存根。