Allow autocomplete from the middle #357

Soares opened this Issue Oct 19, 2012 · 5 comments


None yet

6 participants

Soares commented Oct 19, 2012

This is a long-term feature request, not high priority right now I'm sure. However, one really cool thing that zsh completion can do (if configured correctly, which is a nightmare) is middle-of-word autocompletion. This is really useful in the following scenario:

You're hacking away in share/fish/functions and you want to edit a function, but you don't remember quite what it was named. But you do remember it had 'packages' in it...

> vim share/fish/functions/packages▯<tab>

The first thing that the autocompletion does, which is cool, is fill in as much of the file as it can. All file names in the directory that have 'packages' in their name are of the form, so you get this:

> vim share/fish/functions/▯

Now the autocompleter shows you the possible matches, possibly with the completed part highlighted. "Oh right", you think, "it was crux packages", so you type x<tab> (because x is pretty distinctive) and zsh figures out the rest and away you go.

The above example is a bit contrived, but this feature is actually really cool when you're in a directory where everything has the same prefix and you only vaguely remember part of the filename you're trying to complete. It should definitely only be used if prefix-matching yields no results, though, because best-fit matching is a silly place.

I'd love to see this feature implemented in fish some day.

lucmp commented Nov 29, 2012

I am not sure I like this feature. What if one of the possible completions actually begins with 'x'? Then should it have priority? How so? It appears after the first tab and 'crux' will come up in a second tab? I foresee a rather cluttered bunch of tab results, and I really like shells that do the job in one single tab (fish, tcsh, etc.)

Soares commented Nov 29, 2012

I'd say that this feature should only happen when nothing else starts with x. It's enabled as a fallback when you've typed something that's definitely not a prefix.

This is incredibly useful when you're enumerating through a bunch of numbered files, for example:

> ls
Some TV Show 01.mp4
Some TV Show 02.mp4
Some TV Show 03.mp4
> vlc 03<tab><enter>
[You are now watching episode 3]

And in those scenarios I dearly miss zsh.

257 commented May 14, 2014

this will be a must-have for #1465

@zanchey zanchey added the enhancement label Jul 22, 2014
faho commented Sep 5, 2016

We've actually had this for a while, though it's only really usable after 57f2898.

@faho faho closed this Sep 5, 2016
@faho faho modified the milestone: fish 2.4.0, fish-future Sep 5, 2016
alphapapa commented Sep 20, 2016 edited

Let me just say that this is one of my very favorite features in fish. I absolutely love being able to type any part of a filename and have fish complete on it. Saves so much time and typing! :D

In fact, may I suggest that we highlight this as a feature in the docs or web site somewhere? It's really that good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment