Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable statement completion on space in Eclipse Content Assist

Tags:

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

like image 694
tomash Avatar asked Sep 03 '13 07:09

tomash


People also ask

How do I turn off space autocomplete in eclipse?

In Eclipse go to Window -> Preferences -> General -> Keys and remove the binding for the command Content Assist. That would remove the possibility to bring up the suggestions using ctrl+Space.

How do I turn on autocomplete 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.

How do I autocomplete variables in Eclipse?

Hit Ctrl-Space and up pops a list of all things that you could possibly use, namely local variables, class data fields, class methods, static imports, etc.


2 Answers

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:

  • Eclipse 4.10 - New and Noteworthy - Disable completion insertion triggers
  • The feature here in this video in action.
like image 92
howlger Avatar answered Sep 23 '22 19:09

howlger


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.

like image 35
Meow Cat 2012 Avatar answered Sep 22 '22 19:09

Meow Cat 2012