mapping Tab in the command line

0 views
Skip to first unread message

John Magolske

unread,
Aug 18, 2008, 6:50:01 PM8/18/08
to vim...@googlegroups.com
With wildmenu on, ':b', a space, then 'Tab' while in the command-line
brings up a list of open buffers -- very handy. I tried to automate
this sequence with a mapping like so:

map <leader>b :b <Tab>

But this just shows the Ctrl-I equivalent of Tab on the command line:

:b ^I

Is there a way to create a mapping that will emulate the physical
pressing of the Tab key in this case?

Thanks,

John


--
John Magolske
http://B79.net/contact

Tony Mechelynck

unread,
Aug 18, 2008, 11:50:47 PM8/18/08
to vim...@googlegroups.com

That tab is your 'wildchar', it is not recognized in a mapping. See
":help 'wildcharm'" for its mappable counterpart.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
125. You begin to wonder how often it REALLY is necessary to get up
and shower or bathe.

John Magolske

unread,
Aug 19, 2008, 3:04:23 AM8/19/08
to vim...@googlegroups.com
* Tony Mechelynck <antoine.m...@gmail.com> [080818 23:08]:

>
> On 19/08/08 00:50, John Magolske wrote:
> > With wildmenu on, ':b', a space, then 'Tab' while in the command-line
> > brings up a list of open buffers -- very handy. I tried to automate
> > this sequence with a mapping like so:
> >
> > map<leader>b :b <Tab>
> >
> > But this just shows the Ctrl-I equivalent of Tab on the command line:
> >
> > :b ^I
> >
> > Is there a way to create a mapping that will emulate the physical
> > pressing of the Tab key in this case?
>
> That tab is your 'wildchar', it is not recognized in a mapping. See
> ":help 'wildcharm'" for its mappable counterpart.

Thank you! Works like a charm! (sorry, couldn't resist...)

I put this in the vimrc:

set wildmenu
set wildmode=list:longest,full
set wcm=<C-Z>
map <leader>a :b <C-Z>

Now, with two keystrokes, all buffers present themselves.

Tony Mechelynck

unread,
Aug 19, 2008, 3:39:06 AM8/19/08
to vim...@googlegroups.com

With 'wildmenu' settings similar to yours, I have a mapping to get a
menu even in Console Vim. This needs

if has('menu')
if !has('gui_running')
runtime! menu.vim
endif
map <F2> :emenu <C-Z>
endif

in addition to what you already got. The menu appears on your bottom
status line, Left/Right to select, Down to descend into a submenu, etc.
(It works also in the GUI but it's less necessary.) Note that the
Buffers menu include "groups of buffers" by first letter: currently I
have "others", "abcd", "efgh", "ijkl", "mnop", "qrst" and "u-z". Seeing
how they have quite different numbers of buffers, I believe these groups
might be permanent.

Best regards,
Tony.
--
In Pocataligo, Georgia, it is a violation for a woman over 200 pounds
and attired in shorts to pilot or ride in an airplane.

Reply all
Reply to author
Forward
0 new messages