I would like to map , to have the same effect as typing :b <Tab> in Vim; that is, have the <Tab> trigger the commandline completion to show all buffers.

I tried nnoremap , :b <tab> but I get ^I in the commandline, instead of triggering the completion.


1 Answer 1


This is the expected behaviour; otherwise you'd have the reverse problem: you wouldn't be able to enter a <Tab> character in the commandline.

You'll have to use the feedkeys() function to do this:

:call feedkeys(":b \<Tab>", 'tn')

The t flag in the second argument does the trick; this tells feedkey() to handle keys as if they're typed by the user. See the help page for more information on that.

To map it, use:

:nnoremap , :call feedkeys(":b \<Tab>", 'tn')<CR>
  • 3
    that is not completly true. You just have to :set wildcharm=<tab> and then nnoremap , :b <tab> should just work. Sep 7, 2017 at 20:30
  • Thank you @ChristianBrabandt; I was not aware of that setting. Learning Vim really is like learning to play an instrument: you never stop learning new stuff :-) Sep 7, 2017 at 20:33
  • yeah, it's one of the more obscure settings. Sep 7, 2017 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.