Question

Is there a way to disable auto-completion feature of Eclipse, which inserts currently selected statement in Java Content Assist when pressing space?

I still want to have such a behavior for enter key (and only for enter).

Was it helpful?

Solution

Since Eclipse 2018-12 (4.10) there is a preference for that:

In Window > Preferences: Java > Editor > Content Assist check the checkbox Disable insertion triggers except 'Enter'

See also:

OTHER TIPS

I know this is an old question but the following anwser may help those come here through google.
It is possible, but a bit of complicated.

First we can make sure content assist pop up whenever we type: In Eclipse, open window->Preferences, go to Java->Editor->Content Assist, then enter all 26 letters both upper and lower cases into Auto activation triggers for java:
Enable auto-complete This has been mentioned many times.
To only confirm with enter pressed, download Practical Macro from this answer or directly from this Source Forge page. Drop the jar file in folder dropins under Eclipse's installation directory, restart Eclipse and you will find it:
Practicial Macro in Eclipse
Hit the red button to begin recording, enter space anywhere in the editor then hit the red button again to bring up a save screen. Save the macro with some name, e.g. we use "space" here.
Afterwards go to Preferences again, then General->Keys, enter the name you set before as filter text, find the recorded macro then set its key binding to Space.
Now whenever you hit the space bar, it interrupts content assist from entering its suggested content, though the assist is still shown. You can do the same for the dot key. enter image description here

Tested here:
Enter h to bring up the assist:
enter image description here
Press space bar:
enter image description here
It works! While if i press Enter it still auto completes.

For dot key you may want it to bring up Content Assist again after discard te previous suggestion, so when recording the macro for dot key, press dot key then use Alt+/ to bring up the assist. While replaying you may find the assist empty, that's because it needs delay. Insert some time-consuming command between inserting the dot and bring back the assist, e.g. Organize Import or Format Code.

Not sure if this is what you are looking for, but:

You can disable the hotkey (or set it to a different hot key) in preferences.

  1. Open the preferences window (on a mac, it is Eclipse->Preferences)
  2. Navigate to the Keys window in general > editors > keys
  3. search for 'content assist' in the filter box.
  4. Change or remove the binding (near the bottom of the window)

Not possible as far as I can tell in Kepler. Best solution I've found is to increase the "Auto activation delay (ms)" setting. For me increasing it from the aggressive default of 40 ms to 200 ms worked out well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top