How to effectively use Vim: wildmenu

Vim

Vim Problem Overview


I'm a bit confused about the use of Vim's menus. I have set wildmenu and set wildmode=list:longest,full but I don't understand for the life of me how to invoke and use the completion feature.

Is this feature useful? Why and how? What kind of completion does this do exactly? In other words, what determines the completion list content?

Any tips and example usages would be appreciated.

Vim Solutions


Solution 1 - Vim

wildmenu and wildmode are used for command line completion. The simplest way to try it would be with :color <Tab>: the command line is "expanded" vertically with a list of all the colorschemes available on your machine displayed in columns and an horizontal strip that you can navigate with <Tab> (forward) and <S-Tab> (backward).

The behaviour of command line completion and wildmenu are dependant on wildmode.

See :help wildmode and :help wildmenu for more details.

Solution 2 - Vim

Probably the most comfortable option, at least for me is:

set wildmenu
set wildmode=longest:full,full

That means that on first <Tab> it will complete to the longest common string and will invoke wildmenu (a horizontal and unobtrusive little menu). On next <Tab> it will complete the first alternative and it will start to cycle through the rest. You can go back and forth with <Tab> and <S-Tab> respectively.

An awesome example on how wildmenu is very useful, is to complete buffers, use the config I posted and then try:

:b<Tab>

Solution 3 - Vim

My favorite is

set wildmenu
set wildmode=longest:list,full

First tab will complete to longest string and show the the match list, then second tab will complete to first full match and open the wildmenu.

Solution 4 - Vim

:set wildmode=list:longest allows you to expand the wildmenu.

:set wildmenu allows you to use <Left> or <Right> to navigate through the completion lists.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionskipprView Question on Stackoverflow
Solution 1 - VimromainlView Answer on Stackoverflow
Solution 2 - VimPablo Olmos de Aguilera C.View Answer on Stackoverflow
Solution 3 - VimtrusktrView Answer on Stackoverflow
Solution 4 - VimQuang Linh LeView Answer on Stackoverflow