97

How do I tell Eclipse to automatically make suggestions as I type? I'm looking for a Visual Studio Intellisense-like feature with Resharper.

Currently I have to press CTRL+Space each time.

Mohamed El-Nakeep
  • 6,580
  • 4
  • 35
  • 39
Ian Vink
  • 66,960
  • 104
  • 341
  • 555

6 Answers6

181

I've get closer to VisualStudio-like behaviour by setting the "Autocomplete Trigger for Java" to

.(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

and setting delay to 0.

Now I'd like to realize how to make it autocomplete method name when I press ( as VS's Intellisense does.

Tony
  • 1,811
  • 2
  • 11
  • 2
  • thanks for the tip, thats a little better but still no where near as good as VS! – GreyCloud Feb 02 '11 at 14:11
  • 1
    Which version of eclipse is this? The "Auto activation triggers for Java" textbox lets me enter only 4 characters. – Zesty Feb 03 '11 at 05:26
  • 4
    This works very well. Much better, since it will actually show local variables and everything now. Thanks! @HappyCoder4U This may not help, but I'm using eclipse 3.7M5. – Howler Apr 21 '11 at 18:14
  • 3
    you are genius :) no such setting for non-java languages though :( – Ivan G. Jun 09 '11 at 21:33
  • 1
    Awesome. Thank you! Using Eclipse on Mac (3.6.1) the parameter name is 'Auto activation triggers for Java' – ninjaPixel Jun 18 '11 at 21:58
  • Not sure why the settings aren't like that by default. At 200ms delay, it doesn't even seem to work. – Jack Mar 15 '12 at 00:22
  • 4
    Everything worked but now I get some very irritating behavior: suppose I want to type "private int counter;" I start with private and the autocomplete kicks in with some suggestions (the firt is PrivateCredentialPermission). When I'm done typing private and press "space" PrivateCredentialPermission gets inserted. Any way around this? – VM4 Aug 17 '13 at 18:32
  • 1
    Tony is a pure genius. – MD TAHMID HOSSAIN Sep 17 '13 at 09:41
  • I second on what @VM said. The inclusion of that variable name is rather annoying. – theGreenCabbage Apr 04 '14 at 05:50
  • @VM4 On the "Code Assist Preferences", on "Insertion", check the "Insert common prefixes automatically". – LEMUEL ADANE Oct 23 '14 at 03:12
  • Great idea! and I help me better understand this eclipse feature. – smwikipedia Dec 21 '14 at 07:51
  • See this stack overflow question for some solutions to the space problem: http://stackoverflow.com/questions/14297735/stop-spacebar-keypress-from-triggering-autocomplete-in-eclipse – William Jarvis Feb 19 '15 at 16:19
  • I added space to the list of my list of triggers. This lets me do things like "int x = " and immediately, it shows me a list of method names I can invoke if I so choose. – BrainSlugs83 Apr 18 '15 at 19:00
83

You don't have to press CTRL * space but maybe the delay is too big or you don't like the trigger (default is '.'). Go to

Window -> Preferences -> Java/Editor/Content Assist

And change the settings under Auto Activation to your likings.

If this does not work for windows users then see this answer.

Community
  • 1
  • 1
Daff
  • 43,734
  • 9
  • 106
  • 120
  • 1
    user Kevin Rossi tried to edit to point this (which really is a comment) : "This doesn't work with the Eclipse Juno C/C++ distro" – Denys Séguret Sep 26 '12 at 15:16
  • Each editor in Eclipse may have its own auto activation triggers--activating on the same characters wouldn't make sense in ever language. – nitind May 29 '13 at 13:22
  • In Mac it is `ADT -> Preferences -> Java/Editor/Content Assist` – Adil Malik Oct 14 '13 at 12:59
45

Tony is a pure genius. However to achieve even better auto-completion try setting the triggers to this:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz =.(!+-*/~,[{@#$%^&

(specifically aranged in order of usage for faster performance :)

d3dave
  • 1,361
  • 14
  • 23
  • 2
    This method introduces some bugs. For example, if I type in `=`, it would immediately suggest something. If I press space, `= `, it would automatically insert the first match. – theGreenCabbage Apr 04 '14 at 05:53
  • checking Java proposal, Java Type proposal and java non-type proposal and moving them on top in order, worked for me. – Shailendra Singh Rajawat Jul 10 '14 at 11:20
  • See this stack overflow question for some solutions to the space problem: http://stackoverflow.com/questions/14297735/stop-spacebar-keypress-from-triggering-autocomplete-in-eclipse – William Jarvis Feb 19 '15 at 16:13
  • All of the special characters will make the Intellisense act screwy except for the period. Basically, if you will ever not want it to Intellisense after a character is typed, you don't want it in this list. – Andrew Oct 09 '17 at 16:57
6

If it's not working even when you already have Code Assist enabled, Eclipse's configuration files are probably corrupt. A solution that worked for me (on Eclipse 3.5.2) was to:

  1. Close Eclipse.
  2. Rename the workspace directory.
  3. Start Eclipse. (This creates a new workspace directory.)
  4. Import (with copy) the Java projects from the old workspace.
Rok Strniša
  • 6,781
  • 6
  • 41
  • 53
  • Fixed it for me aswell – Kenci Jan 11 '15 at 12:11
  • Nice Solution, it was really helpful to me, my Eclipse was unable to show intellisense after (.) , I had to use ctrl+space 3 times to show it, Thanks for the nice Solution :-) – Muhammad Apr 20 '15 at 03:22
5

I once had the same problem, and then I searched and found this and it worked for me:

I had got some of the boxes unchecked, so I checked them again, then it worked. Just go to

Windows > Preferences > Java > Editor > Content Assist > Advanced

and check the boxes which you want .

ugo
  • 2,705
  • 2
  • 30
  • 34
user3074382
  • 51
  • 1
  • 4
  • Also you can arrange the proposals in order of your priority. If it is to show methods and properties related to your identifier, put Java Proposals (Task Specific) first – Codeek Sep 23 '20 at 18:22
5

d3dave's answer is cool. However theGreenGarbage mentioned an issue about it which I too find rather annoying. So here's one that doesn't immediately suggest something after '=' sign and when typing blank space:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.(!+-*/~,[{@#$%^&

What I did was simply remove the space and '=' chars from the array :)

Alternatively if you want suggestions when typing blank space, but not after '=' sign:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .(!+-*/~,[{@#$%^&
MuhsinFatih
  • 1,891
  • 2
  • 24
  • 31