Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search in the Vim mapping listing?

Tags:

vim

Using :map provides a list of all mappings in Vim. But, I am unable to search through the list. I am surprised to see it being opened in a different type of window unlike usual Vim help files. Is there a way to have it available in the usual form?

like image 801
Jikku Jose Avatar asked Jul 19 '14 15:07

Jikku Jose


2 Answers

Vim uses its internal pager to display the output of :map, which has pretty limited functionalities (see :h pager for more info).

If you want to access the output of :map in a normal vim buffer, you could use :redir :

:redir @a>    " redirect output to register a
:map
:redir END
:put a        " paste the output of :map in the current buffer

Note that you can redirect to a file, to a variable, etc... See :h redir for more details.

like image 164
Marth Avatar answered Oct 17 '22 10:10

Marth


Don't be surprised. :map is not related at all with :help so there's no reason whatsoever to expect it to work like :help.

You can give :map an argument to narrow-down the listing:

:map ,

With the right values for wildmenu and/or wildmode, you can tab-complete :map:

:map ,<Tab>

You can also list the current mappings with <C-d>:

:map <C-d>

You can also use the mode-specific variants of :map to get a more manageable list:

:imap ,
:nmap ,
:xmap ,
and so on…

But keep in mind that :map only lists custom mappings (made by you or your plugins). If you want a list of default mappings, check out :help index.

--- EDIT ---

So, a recent upvote reminded me of this old answer and it turns out that a new command, :help :filter has been added in the mean time to help with that kind of use case.

You would use it like this to only list your insert mode mapping that use :help pumvisible():

:filter pumvisible imap

Not technically a search, mind you, but a pretty useful addition nonetheless.

like image 37
romainl Avatar answered Oct 17 '22 11:10

romainl