Join the DZone community and get the full member experience.Join For Free
FlexNet Code Aware, a free scan tool for developers. Scan Java, NuGet, and NPM packages for open source security and open source license compliance issues.
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
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." :-)
Opinions expressed by DZone contributors are their own.