 |
Hidden Hippie
Posted by gsporar on February 05, 2008 at 03:44 PM | Comments (5)
This has been written about before - Tor Norbye
wrote a blog entry on this topic,
as did
Charles Ditzel. It is mentioned
in a tutorial
by Randahl Fink Isaksen, and perhaps in other spots.
With
more and more folks trying out the
NetBeans IDE, however,
I continue to see this
discussed
out on the nbusers email list so it is worth repeating
because this feature is one of those that almost seems hidden - even
though it is listed on the IDE's top level Source menu.
Tor pointed out that the name "hippie completion" originated
with the feature in XEmacs.
Wherever the name came from, the concept is simple: in response to a control
key combination, the editor fills in the nearest matching string.
So for example, using NetBeans 6.0, on line 21 of this source file:

I have typed in myBi as the parameter to
System.out.println(). If I then press Ctrl-K
the editor will search backwards through the edit window for the
nearest match and will then fill in the rest of the string for
me:
Note
that the match is done without any sort of context knowledge.
That is an important point because it means that hippie completion is not
smart, at least not in comparison to a standard code completion feature.
The upside though is that it is faster than code completion.
If I had instead pressed Ctrl-Shift-K then the editor would have
searched forward in the edit window and would have wrapped around to the beginning
of the file and continued searching until it found myBig:

Some things to note:
- Press Ctrl-K (or Ctrl-Shift-K) repeatedly to have the editor
suggest other strings that match.
- You don't have to type anything before invoking the feature - if you
do not give it anything to match then the editor will just suggest
the string that is closest to the cursor position.
- As mentioned, when it does its search the editor wraps around
when it reaches the end of the file. It also wraps when it reaches
the beginning. As a result, I always just use Ctrl-K, even when
I want to insert a string that is further down in the file from
where I am currently editing.
- The editor searches all open editor windows for a match,
not just the window for the file that currently has focus.
- NetBeans has had this feature for years and years and prior to
version 6.0 the keybindings were Ctrl-K to search backward and Ctrl-L
to search forward. The addition of so many new features in NetBeans
6.0 required modifying the default keymap and the default forward search
keybinding got changed from Ctrl-L to Ctrl-Shift-K.
- The official names for these features are "Insert Previous
Matching Word" (Ctrl-K) and "Insert Next Matching Word"
(Ctrl-Shift-K). But I prefer to use
the term "Hidden Hippie." :-)
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Hi Gregg,
I don't know if it is possible, but NetBeans team can reuse the same shortcuts used by Eclipse to the migration or at least shared use of NetBeans by Eclipse users - the majority of all IDE user in the Java world.
Nothing to do with quality or comparison, just a chance to a more comfortable migration from one platform to another. Other brilliant feature would be to give the user a chance to select which set of shortcuts he want to use (Eclipse, NetBeans, IntelliJ, etc..)
cheers......
Posted by: felipegaucho on February 08, 2008 at 09:11 AM
-
Hi Felipe!
Thanks for the comment - NetBeans IDE has had for a while now support for keybindings from other tools, specifically emacs and Eclipse. Just go to Tools > Options > Keymap and select the Profile you want.
FYI, there are some bugs in the Eclipse profile, but the fix will be in the M2 milestone build of NetBeans IDE 6.1.
HTH,
Gregg
Posted by: gsporar on February 08, 2008 at 09:20 AM
-
Believe it or not, in my opinion this is one of the most important features of NetBeans. Actually it's one of the reasons why I'm using NetBeans, since it allows very fast code completion with this feature. Since it's not very smart, you can use it anywhere such as comments or plaintext files.
Posted by: serkanc on February 11, 2008 at 08:28 AM
-
Hi Gregg, as an aside, for a given key combination, how can I found out what it does? In emacs, one does Ctrl-h k for help on any key combination. What's the analog in NetBeans?
Related, is there any way to get a listing of what all non-obvious keys do (where "obvious" would be e.g. that typing "a" inserts "a"). I have the NetBeans 6.0 Keyboard Shortcuts & Code Templates, but it's organized by function, and I'd like a lexicographic listing.
TIA, Dave
Posted by: davenull on February 11, 2008 at 09:55 AM
-
davenull -
It took me a while, but I have finally written a blog entry that answers your first question.
For your second question, you might want to try this
plugin
from Sandip Chitale.
HTH, Gregg
Posted by: gsporar on March 10, 2008 at 01:40 PM
|