Disable statement completion on space in Eclipse Content Assist
Asked Answered
T

4

22

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

Tiros answered 3/9, 2013 at 7:44 Comment(2)
I don't think there is a build in way to do it, But if you want you can disable 'auto-completion', and it should trigger only when you hit ctrl+space, that way it will probably solve your issue...Kopans
It would help if you let us know the OS, and programming languages you are working.Bart
E
8

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:

Eady answered 20/12, 2018 at 16:57 Comment(0)
N
3

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.

Nosedive answered 20/7, 2018 at 5:26 Comment(0)
F
2

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)
Foursome answered 2/1, 2014 at 18:49 Comment(3)
I think the user meant how to change the hotkey to select/insert the suggestion appeared from Content Assist rather than the hotkey for making the Content Assist appearRevis
huh, well you can't change the general case, but specific editors let you change it. Eg: Preferences->Pydev->Editor->CodeCompletion etc.Foursome
Thanks! But I'm using the Java editor, so I can't award the bountyRevis
B
1

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.

Billups answered 25/2, 2014 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.