Character-mode matching in tab completion

In my continuing quest to maximize convenience and laziness for tab completion, I’ve now added what I call char-mode matching in Complete::Util (0.44 to be exact). Let’s see this in action by using lcpan.

% lcpan mods -qty[tab]
% lcpan mods --query-type _

% lcpan mods --query-type [tab][tab]
abstract    any         exact-name  name

% lcpan mods --query-type x[tab]
% lcpan mods --query-type exact-name _

What it means by char-mode matching is that, you can type any number of characters and the word will match any string that contains those characters in the right order, even if they are interspersed with other characters. For example, if you type qux then all strings matching the regex /q.*u.*x/ (or /q.*u.*x/i, since by default matching is case-insensitive) will be matched.

Char-mode matching is inspired by the way the AWS CLI’s completer works.

Note that by default, in Complete::Util, normal prefix comparison matching is performed first. If that fails to produce any matches, then word-mode matching is tried. If that also fails to produce any matches, then char-mode matching is performed. Finally, if char-mode matching also fails to return any matches, fuzzy matching is tried.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s