Reputation: 5267
In short, I'd like to provide a help window in a Vim plugin that can detect which shortcuts the user mapped to the plugin's commands in their .vimrc.
Is there a way to see which shortcuts a user may or may not have mapped to a plugin command?
(Note, I'm not looking for a way to see what command a specific shortcut will execute, which is an FAQ easily found).
For example, in a user's .vimrc, they can add a line such as:
map <leader>1 :MyCoolPluginCommand<cr>
And in my plugin interface I want to surface a quick help window that displays a cheetsheet such as
"Cool Command 1: <leader>1"
My only thought would be to try and parse their vimrc and use a complicated set of regular expressions to grab string values. Any better way? Thanks!
[edit] The plugin calls out to a python script, so I also tagged this question with python in the event that makes a solution possible. (Using import vim
so I can eval() stuff).
Upvotes: 2
Views: 115
Reputation: 34044
:map
gives you a list of all mappings; it should be easier to parse than .vimrc.
Also it will show mappings coming from other places (eg system-wide or command-line).
Upvotes: 3