shizhz
shizhz

Reputation: 12501

VIM: How to list all key mappings in the current buffer for a specified plugin

I know how to use nmap, imap and so on to view all key mappings in vim, and how to list which action is bound to a given key binding. But sometimes I want to have a quick look at all key bindings for a given plugin, is there a quick way to do this? I don't want to list all keybindings and search them page by page.

Many thanks in advance.

Upvotes: 1

Views: 872

Answers (1)

Here is a command which get the mappings of a specific plugin in a separate window:

:let pluginName=".vimrc" | let cmdMap="map"
:redir => output | silent execute "verbose ".cmdMap | redir END | new | put=output | execute 'v/^.*\n.*'.escape(pluginName,'./').'/d'
  1. In the first line, change the variable pluginName with any scriptname and cmdMap with any map command.(Input)

  2. In the second line, execute the command which will parse the output.(Result)


You can still map those commands or create a function to get the input from user.

Edit:

To enlarge the use of other mappings commands (like map!) it would be more reliable to use a register name:

:redir @z | silent execute "verbose ".cmdMap | redir END | new | put z | execute 'v/^.*\n.*'.escape(pluginName,'./').'/d'

Upvotes: 5

Related Questions