Today I Learned: Tab completion in the prompt for search, select & friends

First time I’ve ran into this feature (maybe it’s relatively new?) and I thought others might want to know about it.

<tab> and <s-tab> work in the prompt buffer for search and selection by cycling alphabetically through all words in the selection. For example if I have the following selected

tango
foxtrot
alpine
giga
apricot tango
treat

and I select, <s>, split <S>, search </> or anything else that brings up a prompt and start hitting tab then it cycles through each word in alphabetical order. Even better it narrows down based on the characters you type, for example if I type in a then it cycles alpine, apricot, giga, tango. Type in tr and it cycles foxtrot, treat and back to tr. Only seems to work with regexes without special characters. Search for [tr] and press tab and it starts cycling from alpine.

Anyway, super neat feature which I’ll be using a lot from now on as I always used to do
s[match start of word]<ret>E
to quickly select a word but this method is less error prone as you wont accidently match other words that start with the same characters. Additionally it can save some typing if you have

wordThatIDontWantToSelect
wordThatIWantToSelect

it’s just sw<tab><tab><ret> rather than swordThatIW<ret>E

5 Likes

That’s incredible. Can this be added to the wiki so people can discover it in the future?

Wiki is world-editable. Feel free to add this.

Thanks for sharing prion.

I’m not sure that I understand fully what you described. Here’s what I observed:

If in long prose buffer, I select only the first line of text and press s according to what you say, I should be able to cycle between the words contained ONLY in this first line. But pressing <tab> offers me the words of the whole buffer. What trick am I missing?

1 Like

@Delapouite What you describe would be a nice feature. It would introduce different word completion for the search commands.

Yeah in my haste to try out the feature I’d just discovered I only used a small test file. I tried it out with more words and you’re right. The candidates show up bottom right of the screen and it searches the whole file (I’d personally prefer it if it used the current selection but whatever).

By, the way, you get the same fuzzy completion when using <esc> : for all commands, and when typing file paths: try entering /etc/ and pressing <c-n> or <c-p>.