March 11, 2005
Hippie Completion in Eclipse
I have just discovered that Eclipse supports Hippie Completion. It's a
strange name that dates back to emacs (where it first appeared) and it's also
supported in IDEA. The default key binding in Eclipse is ALT-/ and it's
become my new best friend.
Hippie Completion tries to complete immediately (as opposed to offering you
suggestions, which is what happens when you type Ctrl-Space) based on what you typed recently and the surrounding context.
It's a bit hard to describe and actually, there doesn't seem to be any
documentation about it except for the initial
enhancement, which was implemented by an external contributor and promptly
integrated into Eclipse.
What matters to me is that 90% of the time, it inserts the right symbol.
Try it, you'll get hooked.
Update: Alexandru asked me how I found out, it's simple: Ctrl-Shift-l
(that's an "l" as in "little"), which displays the little window you can see at the
top of this article, and which lists all the key bindings available in the
current context. Great way to make discoveries.
Posted by cedric at March 11, 2005 11:16 AM
Netbeans does it, and it had been a favorite feature of mine. I didn't know IDEA did it. Would you or anyone know how to use hippie completion in IDEA?
In IDEA this sounds like SmartType code completion: ctrl-shift-space. Try something like:
StringBuffer buffer = new [ctrl][shift][space]
SmartType is not quite it. SmartType still looks for a Java code element. The advantage of a surrounding context buffer based approach is that it works within comments, it will look up comments when filling Java statements, it will work irrespective of being on the right side of an "=" sign or the left. I don't know much about Eclipse's implementation. Netbeans' hippie word completion worked the way I described, and it was the single biggest regret I had in moving over to IDEA. It was big-time addictive.
NetBeans does not add the import statement automatically.
In IDEA it sounds more like [CTRL]-[space] . Try:
Colletion [CTRL][space] = new Co[CTRL][shift][space]()
Each completition has it's purpose. :)
The mistyped "Colletion" was on purpose, just to show that IDEA don't look at the "Java Clases" for that completition.
I am not sure about what this feature really is, but if you're talking about the old "ctrl-k/ctrl-y" feature in NetBeans editor, it has just been implemented in the last idea EAP version.
IDEA added this in the EAP, but I don't think it's in a release yet. I discovered it by accident - IIRC it's bound to the same keystroke as in emacs. It's very cool.
I this something new in Eclipse? I'm running 3.1M4 and it doesn't show up on my ctrl-shift-l list when I'm in a Java file, and alt-/ doesn't do it either.
Doesn't work for me either...? (ctrl+shift+l) Do you have emacs bindings?
Hippie completion is in 3.1M5a.
On Mac OS X, Hippie complete is Option+/ and the key binding popup is Command-Shift-L
Matt, which EAP of IDEA was it?
Vim has this feature, too: type the first few letters of a word that exists elsewhere in the file, or in another file you have open, and press ^N or ^P -- it will be completed with the next or previous word (respectively) that starts with the same letters. I lean on this feature pretty hard.
Um, emacs has had this for over a decade.
Thank's for catching up to 1992, Eclipse!
For the sake of folks who google here...
what we're talking about is dabbrev-expand for eclipse (in emacs-speak)...
As the "contributor" of this eclipse feature, I'd love to hear any suggestions or cases when it does not work as expected. Please open a bug report and add me "email@example.com" as a CC.
Too late to have it in 3.1 though
Curious; it works on Eclipse 3.1RC1/Mac, but some reason Shift+Cmd+l does not list it among the available key bindings.
This is called "Word Completion" in Eclipse 3.2.2