vimtricks.wiki Concise Vim tricks, one at a time.

How do I get a visual tab-completion menu for Vim commands and filenames?

Answer

:set wildmenu

Explanation

The wildmenu option enhances Vim's command-line completion by showing a horizontal menu of matches above the command line when you press <Tab>. Instead of cycling blindly through completions, you see all available options at once and can navigate them visually — transforming command-line tab completion from a guessing game into an interactive experience.

How it works

  • Add :set wildmenu to your vimrc (or run it as an Ex command)
  • When typing an Ex command, press <Tab> to trigger completion
  • A horizontal bar appears above the command line showing all matching options
  • Press <Tab> or <Right> to move to the next match, <S-Tab> or <Left> to move to the previous
  • Press <CR> to accept the highlighted match, <Esc> to cancel

This works for command names, filenames, buffer names, settings, help topics, and more — anywhere Vim's command-line completion applies.

Example

Type :color and press <Tab>. The wildmenu shows all available colorschemes:

blue  darkblue  default  desert  elflord  evening  industry  koehler  morning

Navigate with <Tab> to highlight different schemes and press <CR> to apply one.

Or type :e src/ and press <Tab> to browse files in the src/ directory visually.

Recommended setup

Add these to your vimrc for the best experience:

set wildmenu
set wildmode=longest:full,full
set wildignore=*.o,*.pyc,*.class,*.swp,node_modules/**
  • wildmode=longest:full,full — first <Tab> completes to the longest common prefix and shows the menu, second <Tab> cycles through full matches
  • wildignore excludes unwanted files from completion results

Tips

  • Without wildmenu, pressing <Tab> in the command line still completes, but it cycles through matches one at a time without a visual display — wildmenu adds the visual bar
  • The wildmode option controls completion behavior independently of wildmenu: longest completes to the longest common string, full cycles through matches, list shows all matches in a list
  • Use wildoptions=pum (Vim 8.2+ or Neovim) to show completions in a popup menu instead of a horizontal bar — this is more familiar to IDE users
  • wildignore patterns also affect expand(), glob(), and commands like :find — they are project-wide exclusion rules
  • Combine with :set path+=** and :find filename<Tab> for a powerful fuzzy-file-finder workflow using only built-in Vim features
  • wildmenu works with :help too: type :help wild<Tab> to see all help topics starting with wild
  • In Neovim, wildmenu is enabled by default — in Vim you must enable it explicitly

Next

How do I edit multiple lines at once using multiple cursors in Vim?