> What are some good guidelines to follow when trying to
> map keys in a plugin?
>
> Currently I have the following setup in my plugin:
>
> I define a "g:GrailsVimMapleader" which defaults to
> <leader>g
>
> Currently, all my plugin's commands are mapped to
> g:GrailsVimMapLeader + another character. This should
> help avoid conflicts, unless of course the user has <leader>g
> mapped already.
>
> If the user wants to use a different set of leader keys,
> the user can change g:GrailsVimMapLeader (for example, to
> <leader><F3> or something.)
>
> However, I realize there's still a chance that key mapping conflicts
> can occur.
Nathan,
:help using-<Plug>
>
> I would like to warn the user about key mapping conflicts, but I don't
> want the warning to be annoying or ever-present until the user fixes it.
>
> I know about the :map <unique> and maparg() function. Can
> anyone give me suggestions for how to gracefully handle keymapping conflicts?
For my own plugin, I have an option that determines how map conflicts
are handled. Here's a snippet from the help that gives a feel for how
it works. (The default value is "mMoOcC".)
"""
The |txtfmtMapwarn| option may be set to a string of the following
character
flags: "mMeEoOcC". The flags may appear in any combination and in any
order.
Lowercase flags affect the handling of map ambiguities, while
uppercase flags
pertain to map conflicts. The meaning of the flags is as follows:
m Use :echomsg to warn about map ambiguities
M Use :echomsg to warn about map conflicts
e Use :echoerr to warn about map ambiguities
E Use :echoerr to warn about map conflicts
o Warn of a particular map ambiguity only once per Vim session
O Warn of a particular map conflict only once per Vim session
c Create the Txtfmt map in case of map ambiguity
C Create the Txtfmt map in case of map conflict
The "once-only" flag: The intent of the o and O flags is to prevent
the user
from being bombarded with the same conflict warning every time he
loads a
Txtfmt buffer. To determine whether a map conflict or ambiguity is
identical
to one for which the user has already been warned, Txtfmt employs the
concept
of a "conflict instance". A conflict instance is defined by a unique
combination of the following:
-map mode
-{lhs} of the Txtfmt map
-{rhs} of the existing map
"""
Sincerely,
Brett Stahlman
>
> Thanks,
> --Nate
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment