Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type ahead autocompletion in Eclipse

Do Eclipse have a plugin for type ahead autocompletion like Visual Studio, so I don't have to destroy my spacebar by pressing Ctrl+Space all the time? (If you don't know how it works in Visual Studio, please don't bother answering.)

And also, can I limit the autocomplete to imported packages, rather than every single Java class on earth? It's fustrating seeing suggestions from awt and swing etc., when I'm working with GWT. And I don't want to add every single Java class to the filter, that's just stupid. (Again, like how it's done in Visual Studio!)

like image 502
Claus Jørgensen Avatar asked Jan 02 '10 10:01

Claus Jørgensen


People also ask

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?

it only works after you have created some variables. you type the first letter/letters and when you click ctrl + space you get a list of all the variables that start with that letter/letters. it's an auto-complete tool...

How do I enable Content Assist in Eclipse?

To enable the Content Assist window to open automatically, go to the Content Assist Preferences page, accessed from Window | Preferences | PHP | Editor | Content Assist and mark the 'Enable auto-activation' checkbox.


2 Answers

My answer may come too late, but maybe will help others searching this feature in eclipse. This workaround works for me (eclipse helios):

Go to Windows -> Preferences -> Java -> Editor -> Content Assist. Here, enable Auto activation and set Auto activation delay to a low value, let's say 50 ms. Then comes the workaround: In Auto activation triggers for java, simply put all the characters: abcdefghijklmnopqrstuvwxyz.

And there you go, just type something.

like image 135
Cristi Avatar answered Oct 16 '22 19:10

Cristi


Regarding your second part, yes you can

  • Open Eclipse
  • Select Window/Preferences from the menu
  • Expand Java/Appearance/Type Filters from the menu on the left
  • Click the "Add package" button, enter "java.awt" (without the quotes) and click OK
  • OK your way out

This will make Eclipse remove any matching classes from the java.awt package from your type ahead list. Very nice...

So "type-ahead" exists in Eclipse (mentioned in this status report in June 2006), but is synonym of auto-completion, most often triggered by CTRL+ Space... (which is not exactly what you are looking for)


To be more specific, the kind of automatic auto-completion (completion while you are typing, with a "Common" or "All" list of possible completions) you have in Visual Studio is not there in Eclipse (actually read below):

alt text

Original answer January 2010:

At least, not without a dedicating plugin.
And even with that plugin, it would have to follow a TemplateCompletionProcessor, meaning it would need a list of characters triggering said completion (again, not what you are looking for), by redefining method getCompletionProposalAutoActivationCharacters().

Update November 2011:

Cristi mentions in his answer (upvoted) a great workaround, which consists adding all the letters as Auto activation triggers for java.
See also "Automatically opening completion window in Eclipse".

From the thread "Eclipse auto-completion ":

Windows -> Preferences -> Java -> Editor -> Content Assist
  • Set delay to: 0 (actually >0 is better: 50, it avoids CPU picks because of constant listening)
  • Set triggers to:
    .(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV WXYZ@

content assist options

like image 24
5 revs Avatar answered Oct 16 '22 18:10

5 revs