So, on Eclipse Luna, I often encounter the situation where I'm typing a method name, but the first autocomplete suggestion is not the method I am looking for but something that is prefix-equivalent but longer, as in this example:
In the example, I just wanted the element(String name)
method, so instead of hitting Return, I type (
instead. The result, quite annoyingly, is this:
This is clearly not what I was looking for. Is there a way to prevent Eclipse from performing auto-complete when I hit open-parenthesis ((
)?
These are my content assist settings (aparrently, I don't have code recommenders installed at all in this eclipse installation):
Open menu Window, then Preferences. Follow path Java -> Editor -> Content assist. Now mess around with the settings to find your ideal setup. I believe what you'll want is to deactivate Insert single proposals automatically.
IntelliSense is actually Microsoft's implementation of auto-completion, used in Visual Studio. Eclipse has a similar feature. It's called Content Assist. If for some reason yours is turned off (like the way how mine magically did) , here's how to re-enable it.
Install on Eclipse IDE to get advanced Java code completions Codota completes lines of code based on millions of open source Java programs and your context helping you code faster with fewe...
Step 1: Open your Eclipse or Spring Tool Suite, then go to the Window > Preferences as shown in the below image. Step 2: In the next screen go to the Java > Editor > Content Assist > Auto activation triggers for Java as shown in the below image.
In Eclipse 4.11 (2019-03), and possibly earlier, the answer to this is under Preferences → Java → Editor → Content Assist → Disable insertion triggers except 'Enter'. After I checked that box, editing became a lot less annoying.
I have no idea why Eclipse doesn't do it by default. Who types map.put(
and wants that to autocomplete to map.compute()
?
A hack for this is to change the way Eclipse sorts the proposals.
You can go to Preferences
menu and then go to the section for which you want to edit sorting. Then to de Editor
section and Content Assist
.
For example, for Java editor, it will be Preferences > Java > Editor > Content Assist
.
There you will see, more or less in the middle of the window, a section called Sorting and filtering
. Inside there is an option called Sort proposals
which you can change from by relevance
to alphabetically
. Save an close.
With this you will get the proposals list order alphabetically and element()
will be before other methods starting by element
.
EDIT:
Tested in Eclipse Luna running in Ubuntu 14.04 and it works. You'll still get your code completed when writing (
but it will be completed with the shorter option available in the proposals list. If you want to use another method, you can continue writing some letters and the shortest option will disapear of proposals as it doesn't match what you are writing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With