How do I trigger wildmenu completion from inside a custom mapping in Vim?
Answer
:set wildcharm=<Tab>
Explanation
The wildchar option (default <Tab>) triggers wildmenu completion on the command line. But <Tab> cannot be embedded literally in a mapping's right-hand side — pressing it finishes the mapping before completion runs. The wildcharm option provides a second trigger that can be used inside mappings, giving you inline completion from your own key bindings.
How it works
wildchar— the key that opens the wild menu interactively (default<Tab>)wildcharm— a parallel trigger that works insidecnoremapandnnoremapexpressions; does nothing when typed directly
Set wildcharm to <Tab> once in your config:
set wildcharm=<Tab>
Now you can embed <Tab> in normal-mode mappings to trigger completion:
nnoremap <Leader>e :e **/<Tab>
nnoremap <Leader>b :buffer <Tab>
Example
After :set wildcharm=<Tab>, pressing <Leader>e opens the command line pre-filled with :e **/ and immediately opens the wildmenu, letting you fuzzy-navigate to any file in the project without a plugin.
:e **/<wildmenu shown here>
foo/bar/baz.go
foo/bar/qux.go
...
Use <Tab> / <S-Tab> to cycle through matches and <CR> to confirm.
Tips
- Combine with
set wildmode=list:fullandset wildignoreto filter noisy paths - Works with any Ex command that accepts completion:
:buffer <Tab>,:help <Tab>,:colorscheme <Tab> wildcharmis unset (0) by default — you must enable it explicitly