views:

362

answers:

2

Hi

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

Thanks!

+1  A: 

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:

alt text

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

VonC
I know that, and I wrote as part of the question that I didn't want to do this, as it's ridiculous stupid to add all classes in Java to the filter!
Claus Jørgensen
@Claus: even if you can enter packages instead? Anyhow, I am not aware of other "auto-completion" mechanisms.
VonC
As I wrote, I want to only show the imported packages, not filter out everything I don't need.
Claus Jørgensen
Thanks for the updates. If Eclipse absolutly needs a TemplateCompletionProcessor I guess we can conclude that Eclipse is simply to poorly programmed to be able to have features Emacs had for decades. Sad :(
Claus Jørgensen
Other relevant links on the eclipse side: http://wiki.eclipse.org/FAQ_How_do_I_add_Content_Assist_to_my_editor%3F and http://wiki.eclipse.org/FAQ_How_can_Content_Assist_make_me_the_fastest_coder_ever%3F
VonC
A: 

Completion is triggered when pressing ".", if that is what you are referring to as "type-ahead autocompletion". This is what Visual Studio also does, unless you are referring to another Visual Studio feature I'm unaware of.

Limiting completion to only imported packages I think is a somewhat unorthodox thing to do; you are forced to rely on wildcard imports to define the set of types to complete on. I think most users would consider that less than useful. You're welcome to elaborate on your use case for this, though. For example, why would you want to exclude all Java classes from completion?

BTW, using "type filters" (as VonC suggests) doesn't require you to add every single class. I typically (globally) exclude java.awt.*, sun.com.*, org.omd.*, and a few others. Eclipse also sorts completion according to a (type-sensitive) heuristic which usually results in the most relevant types being displayed at the top. For example, auto-completion inside a method call will put the variables which matches the method type signature at the top.

JesperE
No, Visual Studio have type ahead on everything, not just methods. This is why I requested people to actually have experience with Visual Studio, instead of answering from what they THINK that Visual Studio does.
Claus Jørgensen
Correction to that, only Visual Studio 2008 for .NET technologies have it. If you only used VS for C++, you wouldn't have experienced it.
Claus Jørgensen
I don't have access to any .NET-enabled VS at the moment to try, but how are the completions displayed? A drop-down menu like the one triggered on "." seems a bit invasive.
JesperE
it's not invasive, it's extremely handy, specially as the VS intellisense is clever and suggest previously used variables from the line above, etc. You need to consider that the VS version isn't as extremly slow as Eclipse's, and that it's a much cleaner and minimalistic layout. Not big and bulky, and it don't threadblock your typing like Eclipse.
Claus Jørgensen
@Claus, I find it invasive, because sometimes I want to type the name of a method that I haven't written yet but am planning to write in a few minutes. It's very confusing when VS "corrects" my spelling by substituting the name of a class from the framework.
finnw