💾 Archived View for pwshnotes.flounder.online › gemlog › 2022-10-23-vim-wildmenu.gmi captured on 2024-03-21 at 15:15:24. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
When you are working on the Vim command line, you can press the Tab key to complete the current command. Vim will fill in a complete file name or option depending on what letters you've typed so far. Then, each press of Tab will cycle through the possible completions. Each time the command will be fully typed. And each possible completion is based on only what the user typed.
One way to preview possible completions is by using Ctrl-D. To see this, type as much of your command as you want. Then press Ctrl-D. This prints all the options above the command line. But none of these can be selected. They're just visual aids for you.
It would be nice if I could select from among the possible completions.
Vim is able to provide a dynamic menu which will give you a list of options. This list pops up above the command line. And you can use the arrow keys or tab key to select which option you want. After selecting your option, you would press the Enter key to execute the complete command.
You need a vimrc file. I have mine saved here:
$HOME/.vim/vimrc
To enable the menu, you have to add the following options to your vimrc file and save.
set wildmenu set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
'wildignore' specifies a list of file types which won't be offered while using tab completion.
After saving your vimrc, close Vim and reopen it.
Now, when you press Tab to complete a command, you will be presented with a menu.
For example, pressing Tab after ":help vimrc" shows the following options above the command line:
vimrc .vimrc _vimrc vimrc-intro vimrc-filetype vimrc_example.vim ... :help vimrc
By default, the 'wildmenu' option shows possible completions horizontally. There is an alternative menu which will show completions vertically.
Add the pum option to show the vertical menu instead.
set wildmenu set wildoptions=pum set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
'wildmenu' example | freeCodeCamp
'wildmenu' and "pum" menu | Vim Help
Created: Sunday, October 23, 2022
Updated: Sunday, October 23, 2022