Eclipse: Enable autocomplete / content assist
Asked Answered
B

11

192

How can I enable autocomplete in Eclipse? I can't find it!

Boru answered 2/8, 2011 at 12:37 Comment(0)
G
223

By default in Eclipse you only have to press Ctrl + space for autocomplete. Then select the desired method and wait 500ms for the javadoc info to pop up. If this doesn't work go to the Eclipse Windows menuPreferencesJavaEditorContent assist and check your settings here

Gorski answered 2/8, 2011 at 12:52 Comment(10)
Is there a way to get it to show up without hitting ctrl-space?Oui
@MikeG Go to 'Window Menu > Preferences > General > Keys'. If you then select 'Content assist' you can change the default key binding.Gorski
Change the default in Auto activation triggers for Java to ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ #1960446Dozier
@Dozier Where is "default in Auto activation triggers for Java"? I couldn't find it. (Using 23).Nakasuji
Also, keep in mind that not all the classes have javadoc associated with them, so even with correctly configured environment, the help won't show up for such classes for obvious reasons. (I.e. if you don't see the dialog show up even after all the suggestions here, make sure there's javadoc indeed for the class/method you're trying to get assist for.)Mossback
@kRiZ, Eclipse > Preferences > Java > Editor > Content Assist. In the bottom pane "Auto Activation" there's the field "Auto activation triggers for Java".Besse
@Dozier I know there is a way of making the autocomplete use the first suggestion by default, so if you write syso you press ctrl + space and you get System.out.println(); without having to press enter. However I cant remember how to set it so that enter is not necesarySuzan
@Suzan I am pretty sure that this isn't possible at the moment without addons.Xanthine
when using spring you will have to install sts 3 from eclipse marketplace and then change perspective to spring and open xml config files using spring config editor for autocomplete to work.Saucier
Im getting 'this compilation unit is not on a build path' :(Contrapositive
M
252

If you would like to use autocomplete all the time without having to worry about hitting Ctrl + Spacebar or your own keyboard shortcut, you can make the following adjustment in the Eclipse preferences to trigger autocomplete simply by typing several different characters:

  1. Eclipse > Preferences > Java > Editor > Content Assist
  2. Auto Activation > Auto activation triggers for Java
  3. Enter all the characters you want to trigger autocomplete, such as the following:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._

Now any time that you type any of these characters, Eclipse will trigger autocomplete suggestions based on the context.

Manque answered 17/9, 2015 at 1:10 Comment(6)
This makes Eclipse's content assist behave more like IntelliJ's and Netbeans. Really helpful +1Xanthine
@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._ help for annotationsHighmuckamuck
Isn't there an option for regular expression? like [a-zA-Z]?Cymophane
@Cymophane I kind of doubt it, but I have no idea. Tbh I copied this answer from a comment on the accepted answer and it blew out of proportion. I don't even use Eclipse anymore.Manque
I tried the solution but isn't it a little bit annoying that you can't use keywords anymore without pressing ESC to avoid the content assistance? For example: if I type else I immediately get the assistance for EditableWSDLService which is overtaken immediately by pressing the space bar. So I cannot write with natural flow anymore. For that reason I went back to the default setting of content assistance.Lamprophyre
Also remember to check the box: "Disable insertion triggers except 'Enter'", otherwise, it will annoy you when typingSoria
G
223

By default in Eclipse you only have to press Ctrl + space for autocomplete. Then select the desired method and wait 500ms for the javadoc info to pop up. If this doesn't work go to the Eclipse Windows menuPreferencesJavaEditorContent assist and check your settings here

Gorski answered 2/8, 2011 at 12:52 Comment(10)
Is there a way to get it to show up without hitting ctrl-space?Oui
@MikeG Go to 'Window Menu > Preferences > General > Keys'. If you then select 'Content assist' you can change the default key binding.Gorski
Change the default in Auto activation triggers for Java to ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ #1960446Dozier
@Dozier Where is "default in Auto activation triggers for Java"? I couldn't find it. (Using 23).Nakasuji
Also, keep in mind that not all the classes have javadoc associated with them, so even with correctly configured environment, the help won't show up for such classes for obvious reasons. (I.e. if you don't see the dialog show up even after all the suggestions here, make sure there's javadoc indeed for the class/method you're trying to get assist for.)Mossback
@kRiZ, Eclipse > Preferences > Java > Editor > Content Assist. In the bottom pane "Auto Activation" there's the field "Auto activation triggers for Java".Besse
@Dozier I know there is a way of making the autocomplete use the first suggestion by default, so if you write syso you press ctrl + space and you get System.out.println(); without having to press enter. However I cant remember how to set it so that enter is not necesarySuzan
@Suzan I am pretty sure that this isn't possible at the moment without addons.Xanthine
when using spring you will have to install sts 3 from eclipse marketplace and then change perspective to spring and open xml config files using spring config editor for autocomplete to work.Saucier
Im getting 'this compilation unit is not on a build path' :(Contrapositive
S
17
  1. window->preferences->java->Editor->Contest Assist
  2. Enter in Auto activation triggers for java:
    abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._
  3. Apply and Close

other method:
type initial letter then ctrl+spacebar for auto-complete options.

Sirloin answered 22/8, 2018 at 14:48 Comment(1)
Welcome to Stack Overflow! Please note you are answering a seven years old already answered question.Here is a guide on How to Answer.Buckra
N
9

For auto-completion triggers in Eclipse like IntelliJ, follow these steps,

  1. Go to the Eclipse Windows menu -> Preferences -> Java -> Editor -> Content assist and check your settings here
  2. Enter in Autocomplete activation string for java: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._@
  3. Apply and Close the Dialog box.

Thanks.

Nutriment answered 20/10, 2019 at 7:7 Comment(0)
G
5

For anyone having this problem with newer versions of Eclipse, head over to Window->Preferences->Java->Editor->Content assist->Advanced and mark Java Proposals and Chain Template Proposals as active.

Grizelda answered 20/9, 2020 at 10:11 Comment(0)
E
3

I am not sure if this has to be explicitly enabled anywhere..but for this to work in the first place you need to include the javadoc jar files with the related jars in your project. Then when you do a Cntrl+Space it shows autocomplete and javadocs.

Exhalation answered 2/8, 2011 at 12:49 Comment(1)
I don't have .jars... just a lot of .java filesContrapositive
A
2

If you are only unfamiliar with the auto-complete while typing syntax or inbuilt methods in the eclipse you can simply type the desired syntax or method name and press Ctrl+Space that will display the list of desired options and you can select one of them.

If the auto-complete option is not enabled then you have to check your settings from Windows menu -> Preferences -> Java -> Editor -> Content assist

Alvinalvina answered 2/5, 2016 at 1:55 Comment(0)
C
0

If the auto-complete option is not enabled then you have to check your settings from Windows menu -> Preferences -> Java -> Editor -> Content assist->Advanced and mark Java Proposals and Chain Template Proposals .

Caerphilly answered 9/11, 2021 at 11:58 Comment(0)
P
0

In Eclipse click Windows Drop-Down > Click Preferences > Navigate to Java > Editor > Content Assist In order to Make the Auto suggestion/completion to work you have to set trigger that invoke the Auto Completion.

Now go to, Auto Activation > Auto activation triggers for Java

Enter all the characters you want to trigger autocomplete to be invoked in Eclipse IDE, such as the following:

Alpahabets: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

OR

Special Characters: ~!@#$%^&*()_+=-:;'"|?/.,

OR

Any combination of Alpahabets & Special Characters.

Now based on the references, Eclipse will trigger autocomplete suggestions for you.

Purim answered 20/3, 2022 at 7:8 Comment(0)
R
0

If you are programming in Java, make sure these setting are applied:

enter image description here

Roulers answered 18/4, 2023 at 21:38 Comment(0)
S
-2

For me, it helped after I changed the theme to 'mac' since I am running on a MacOSX.

Eclipse: >Preferences > General > Appearance > Choose 'Mac' from the menu.

Slapjack answered 14/12, 2012 at 6:9 Comment(1)
This is irrelevant to the Contest Assist, you are just changing the theme of the editor :) -1Xanthine

© 2022 - 2024 — McMap. All rights reserved.