Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I keep Eclipse from filling in auto-completions when I type an opening parenthesis ('(')?

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:

Unhelpful autocomplete suggestions

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:

After accidentally triggering autocomplete

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): Content assist settingsenter image description here

like image 590
Jannik Jochem Avatar asked Aug 05 '14 15:08

Jannik Jochem


People also ask

How do I stop eclipse auto-completion?

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.

What is IntelliSense in eclipse?

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.

Does Eclipse have code completion?

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...

How do I use autosuggestion in eclipse?

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.


2 Answers

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()?

like image 192
Trambelus Avatar answered Oct 10 '22 23:10

Trambelus


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 proposalswhich 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.

like image 34
Isthar Avatar answered Oct 10 '22 23:10

Isthar