Eclipse 自动完成刺激
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6145241/
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
Eclipse autocomplete irritation
提问by Ted Hopp
I seem to frequently trip over a particular "feature" of Eclipse's autocomplete behavior. Say that I'm programming in Java and start to code a method call like this:
我似乎经常被 Eclipse 自动完成行为的一个特定“特性”绊倒。假设我正在用 Java 编程并开始编写这样的方法调用:
for (int i = 0; i < n; ++i) {
thing.
When I type the .
, Eclipse pops up a list of candidate methods for thing
. Suppose I select method(int index)
. Eclipse inserts my choice:
当我输入 时.
,Eclipse 会弹出一个候选方法列表thing
。假设我选择method(int index)
. Eclipse 插入我的选择:
for (int i = 0; i < n; ++i) {
thing.method(index)
It also highlights index
and pops up a list of variables I might want to use. The first item on the list is index
and the second one is i
. Not wanting to move my hands from the keyboard, I type i
.
它还突出显示index
并弹出我可能想要使用的变量列表。列表中的第一项是index
,第二项是i
。不想将手从键盘上移开,我键入i
。
The problem is, I then out of habit usually press enter
to complete the autocompletion sequence. Unfortunately, this causes Eclipse to select the first item on the suggestion list that starts with i
, which is index
. Argh! To avoid this, I need to either:
问题是,我再出于习惯通常按enter
来完成自动完成序列。不幸的是,这会导致 Eclipse 选择建议列表中以 开头的第一项i
,即index
。啊!为了避免这种情况,我需要:
- remember to press
tab
instead ofenter
after typingi
; - select
i
from the suggestion list instead of typing it; - press
esc
(twice!) to get rid of the suggestion list before pressingenter
.
- 记住按
tab
而不是enter
在键入后i
; i
从建议列表中选择而不是输入;- 按
esc
(两次!)在按之前删除建议列表enter
。
With all of these, I'm forced to interrupt my thinking about my code in order to think about how to use Eclipse.
有了所有这些,我不得不打断我对代码的思考,以便思考如何使用 Eclipse。
I realize that this is a long-winded rant for a fairly niggling problem, but I do actually have a question. Are there any settings in Eclipse (short of turning off autocompletion, which is otherwise very helpful) to either (1) tell it to rank legal options above illegal ones in the suggestion list or (2) otherwise tell Eclipse that when I type an i
, that's what I want?
我意识到这是对一个相当琐碎的问题的冗长咆哮,但我确实有一个问题。Eclipse 中是否有任何设置(除了关闭自动完成功能,否则非常有用)要么(1)告诉它在建议列表中将合法选项排在非法选项之上,要么(2)以其他方式告诉 Eclipse,当我输入时i
,这就是我想要的?
采纳答案by Robert Munteanu
In the 'Java -> Editor -> Content Assist' preference page set 'Fill method arguments and show guessed arguments' to 'Insert best guessed arguments'
在“Java -> Editor -> Content Assist”首选项页面中,将“Fill method arguments and show guessed arguments”设置为“Insert best guessed arguments”