On Sun, 27 Sep 2009 14:58:25 +0900, Hari Krishna Dara <[email protected]> 
wrote:
> I need to be able to create an imap for <Tab> when my plugin is
> toggled on, and unmap it when it is toggled off. What I would prefer
> is to restore the previous map of <Tab> rather than simply unmap it,
> but there is no straight-forward way to capture the existing map such
> that it can be restored later. I first ventured into capturing the
> output of :imap command and extract the <rhs>, but this won't work for
> many scenarios (including the case of <script>). Even if Vim has a
> command or function to output a script to recreate the map, it won't
> work for all scenarios (e.g., the <script>), so I think what I need is
> a command to create a "copy" of an existing map.

I agree with you on the idea.  It's not possible to perfectly copy
existing key mapping as far as I know - we can get the rhs of a key
mapping with maparg() or mpcheck() but it's not possible to determine
whether <buffer>/<expr>/<script>/<silent> were given for the key
mapping.  Alternative way is to parse output of :map commands, but it's
messy and it's not possible to determine whether <expr>/<silent> were
given.  Even if we can get the information on <expr>/<script>, it's not
possible to recreate the same key mapping for <script> one.

Recently I need to copy a key mapping to enhance my plugin.  It defines
another kind of key mappings which is expanded when multiple keys are
simultaneously pressed.  These key mappings can coexist with ordinary
key mappings even if both {lhs}es conflict with each other, but it's
a bit difficult or troublesome to resolve conflicts manually.  I want to
resolve conflicts automatically, but it's not possible to realize
without the way to copy existing key mappings.  (I also want a function
version of :map_l to get the information of a series of key mappings to
realize the feature.)


-- 
To Vim, or not to Vim.
http://whileimautomaton.net/


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui