On 03/06/09 03:48, Nathan Neff wrote:
>
> In short, I'd like to have an auto-updating menu that shows the
> keyboard shortcuts for my custom-commands. The menu should display the
> command, and the keyboard shortcuts. Even if I change the keyboard
> shortcut for a command, the next time I start Vim, the menus would
> change to reflect
> the new keyboard shortcut.
>
> Any ideas?
>
> Here's a more detailed explanation:
> Suppose I have a custom menu that has all my cool Vim
> shortcuts& commands.
>
> The menu looks like this:
>
> MyMenu
> FooCommand \c
> BarCommand \a
>
> Then, I update the key mapping for "FooCommand" to \z
> I'm too lazy to update my custom menu, so I would like
> Vim to auto-update my menu the next time Vim starts, so
> it would display the new \z key mapping for FooCommand
>
> FooCommand \z
> BarCommand \a
>
> To do this, I need to find a way to get a list of key mappings for certain
> commands, so I could say something like:
>
> exe "menu FooCommand<Tab>" . getMappingFor("FooCommand") . " :FooCommand<CR>"
>
> I've searched the help, vim.org, and the mailing list, and haven't found a
> function or script that does the above.
>
> I've found:
>
> hasmapto()
> mapcheck()
> maparg()
>
> And none of these functions return the actual key mapping for some command.
>
> I guess I could write a function that would parse the output of the
> :map command.
> Before writing such a function, I wanted to check the mailing list.
>
> Thanks in advance,
>
>
> --Nate
:map
will type out all your normal/visual/operator-pending mappings (if any);
similarly with :map! for Insert/Command-line. In a script, you may want
to use
0verbose map
to make sure that Vim does _not_ display where the mapping was defined.
You can capture that output with the :redir command (even IIRC when
using the :silent prefix to avoid scrolling them all on the display).
Beware that there are sometimes additional letters saying if the map is
limited to some modes, has the <buffer> and/or <expr> modifiers, etc.
Some of these appear right before the {rhs} with no intervening space,
so you may have to do some fiddling around with the :redir output to
separate the {rhs}.
See
:help :map_l
" also the paragraph above it
:help map-listing
:help :verbose
:help :redir
Best regards,
Tony.
--
The chicken that clucks the loudest is the one most likely to show up
at the steam fitters' picnic.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---