Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to effectively use Vim: wildmenu

Tags:

vim

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.

like image 460
skippr Avatar asked Mar 01 '12 05:03

skippr


People also ask

How do I use Wildmenu in 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. Is there a way so that if you hit tab, you could scroll through the completion lists? just :set wildmenu=list:full instead.

What is Wildmenu?

"set wildmenu" enables a menu at the bottom of the vim/gvim window. The meaning of "list:longest,full" is so that when you do completion in the command line via tab, these events will happen: 1. (on the first tab) a list of completions will be shown and the command will be completed to the longest common command. 2.


2 Answers

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.

like image 127
romainl Avatar answered Sep 20 '22 16:09

romainl


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>

like image 20
Pablo Olmos de Aguilera C. Avatar answered Sep 20 '22 16:09

Pablo Olmos de Aguilera C.