On Sun, Sep 27, 2009 at 3:00 AM, Jürgen Krämer <[email protected]> wrote: > > > Hi, > > Hari Krishna Dara 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. Using such a command, >> I can "copy" the existing map to a <Plug> map and when I need to >> restore it, "copy" back to the original. The implementation of such a >> copy should be simpler than other alternatives, assuming it involves >> an actual copy of the underlying map data from the source. I think the >> command can fall into the existing map family of commands, rather than >> become a completely new command, something like "[nvxsoilc]mapc[opy] >> <newlhs> <oldlhs>". Does anyone have a clue on the feasibility of such >> a command or a better alternative? Is there a workaround that doesn't >> required creating this new command? > > have you had a look at the maparg() function? >
I am aware of this function, it doesn't tell you what options were used to create the original map, it just gives you the <rhs>. If a plugin created the map using <SID> functions, you can't recreate even if you know what the <rhs> is, as you no longer have the script context. -- Hari > Regards, > Jürgen > > -- > Sometimes I think the surest sign that intelligent life exists elsewhere > in the universe is that none of it has tried to contact us. (Calvin) > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
