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
request for
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.
#1 by Sumit on March 11, 2005 - 11:44 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?
#2 by Jim Clark on March 11, 2005 - 2:06 pm
In IDEA this sounds like SmartType code completion: ctrl-shift-space. Try something like:
StringBuffer buffer = new [ctrl][shift][space]
#3 by Sumit on March 11, 2005 - 2:18 pm
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.
#4 by Anonymous on March 12, 2005 - 7:22 am
Sumit,
NetBeans does not add the import statement automatically.
#5 by Rafael Alvarez on March 12, 2005 - 9:03 am
In IDEA it sounds more like [CTRL]-[space] . Try:
Colletion [CTRL][space] = new Co[CTRL][shift][space]()
Each completition has it’s purpose.
#6 by Rafael Alvarez on March 12, 2005 - 9:05 am
The mistyped “Colletion” was on purpose, just to show that IDEA don’t look at the “Java Clases” for that completition.
#7 by Davide Baroncelli on March 13, 2005 - 6:35 am
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.
#8 by Matt Cornell on March 13, 2005 - 8:10 am
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.
#9 by Mocky Habeeb on March 14, 2005 - 5:42 am
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.
#10 by Anders on March 14, 2005 - 6:12 am
Doesn’t work for me either…? (ctrl+shift+l) Do you have emacs bindings?
#11 by Dave Landers on March 14, 2005 - 1:18 pm
Hippie completion is in 3.1M5a.
On Mac OS X, Hippie complete is Option+/ and the key binding popup is Command-Shift-L
#12 by The Room on March 16, 2005 - 8:23 am
links for 2005-03-16
1. Introducing Quixote: A Simple Link Display A web platform in python (categories: python web programming) XML development with…
#13 by Sumit on March 17, 2005 - 12:23 pm
Matt, which EAP of IDEA was it?
#14 by Ryan Platte on April 4, 2005 - 7:17 am
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.
#15 by Anonymous on April 6, 2005 - 7:01 am
Um, emacs has had this for over a decade.
Thank’s for catching up to 1992, Eclipse!
#16 by Greg on May 24, 2005 - 8:47 am
For the sake of folks who google here…
what we’re talking about is dabbrev-expand for eclipse (in emacs-speak)…
#17 by Anonymous on May 30, 2005 - 3:26 pm
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 “eclipse@genady.org” as a CC.
Too late to have it in 3.1 though
Genady
#18 by Michel on June 6, 2005 - 11:41 am
Curious; it works on Eclipse 3.1RC1/Mac, but some reason Shift+Cmd+l does not list it among the available key bindings.
#19 by Eric on June 21, 2007 - 1:16 pm
This is called “Word Completion” in Eclipse 3.2.2