Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

java - Stop spacebar keypress from triggering autocomplete in Eclipse

Update

This was fixed in Eclipse 2018-12. This behaviour is still default, but can be configured off - see the accepted answer for how

I'll leave the question as it was for posterity, and for those on earlier versions of Eclipse


In Eclipse, I've enabled intellisense-style suggestions for Java by going to

Window -> Preferences -> Java/Editor/Content Assist

and setting the following

Auto activation delay (ms) -> 0
Auto activation triggers for Java -> .(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

source = Eclipse Intellisense?

This works brilliantly, apart from one annoying problem. When I hit spacebar, the token being typed is autocompleted with whatever is at the top of the suggestions list. Fair enough, except that sometimes I'll type a class/variable name with an exact legal match, but this won't appear as the top suggestion. So when I naturally hit spacebar Eclipse inserts something completely wrong.

E.G. after typing Cookie I'll hit spacebar and get CookieMonster.

This seems like a bug, and happens often enough to be annoying, but even despite this I don't want spacebar to trigger autocomplete in general. I may want to type a variable name which hasn't been declared yet, or something similar. I want to use autocomplete as a helper tool, but my natural typing should always take priority over it.

I'd like to stop spacebar triggering autocomplete, and either fall back to using enter, or better still trigger autocomplete with a custom key not used in ordinary typing. Is any of this possible?

I've played around with all the settings in Content Assist to no avail. Googling the question just returns a bunch of results about disabling the autocomplete feature.


This issue is fixed from Eclipse 2018-12 [4.10] see the accepted answer

It's present in all prior versions, i.e. 2018-09 [4.9], Photon [4.8], Oxygen [4.7], Neon [4.6], etc..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is a solution on the issue tracker for this. Copy the jar in the eclipse/dropins folder. With the next restart space is diabled as autocompletion trigger.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=348857

Eclipse 12-2018 and newer: This is working natively, check Pyves answer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...