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

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?

Posted by: Sumit at March 11, 2005 11:44 AM

In IDEA this sounds like SmartType code completion: ctrl-shift-space. Try something like:

StringBuffer buffer = new [ctrl][shift][space]

Posted by: Jim Clark at March 11, 2005 02:06 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.

Posted by: Sumit at March 11, 2005 02:18 PM


NetBeans does not add the import statement automatically.

Posted by: at March 12, 2005 07:22 AM

In IDEA it sounds more like [CTRL]-[space] . Try:

Colletion [CTRL][space] = new Co[CTRL][shift][space]()

Each completition has it's purpose. :)

Posted by: Rafael Alvarez at March 12, 2005 09:03 AM

The mistyped "Colletion" was on purpose, just to show that IDEA don't look at the "Java Clases" for that completition.

Posted by: Rafael Alvarez at March 12, 2005 09:05 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.

Posted by: Davide Baroncelli at March 13, 2005 06:35 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.

Posted by: Matt Cornell at March 13, 2005 08:10 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.

Posted by: Mocky Habeeb at March 14, 2005 05:42 AM

Doesn't work for me either...? (ctrl+shift+l) Do you have emacs bindings?

Posted by: Anders at March 14, 2005 06:12 AM

Hippie completion is in 3.1M5a.

On Mac OS X, Hippie complete is Option+/ and the key binding popup is Command-Shift-L

Posted by: Dave Landers at March 14, 2005 01:18 PM

Matt, which EAP of IDEA was it?

Posted by: Sumit at March 17, 2005 12:23 PM

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.

Posted by: Ryan Platte at April 4, 2005 07:17 AM

Um, emacs has had this for over a decade.

Thank's for catching up to 1992, Eclipse!

Posted by: at April 6, 2005 07:01 AM

For the sake of folks who google here...

what we're talking about is dabbrev-expand for eclipse (in emacs-speak)...

Posted by: Greg at May 24, 2005 08:47 AM

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 "" as a CC.

Too late to have it in 3.1 though


Posted by: at May 30, 2005 03:26 PM

Curious; it works on Eclipse 3.1RC1/Mac, but some reason Shift+Cmd+l does not list it among the available key bindings.

Posted by: Michel at June 6, 2005 11:41 AM

This is called "Word Completion" in Eclipse 3.2.2

Posted by: Eric at June 21, 2007 01:16 PM
Post a comment

Remember personal info?