sponsor Vim development Vim logo Vim Book Ad

savemap.vim : savemap is the library to save current mapping(s)/abbreviation(s)

 script karma  Rating 0/0, Downloaded by 1119  Comments, bugs, improvements  Vim wiki

created by
tyru
 
script type
utility
 
description
Repository: http://github.com/tyru/savemap.vim

Requirements:
- Vim 7.3 or higher


|savemap| is the library to provide a way
to restore current mapping(s)/abbreviation(s) "perfectly".

...But remember, you can always use |:map-<buffer>| for "simple" case.

>
    nmap foo blahblahblah

    let foo_nmap = savemap#save_map('n', 'foo')
    if empty(foo_nmap)
        echoerr 'your vim version is lower than 7.3.032!'
    endif

    nmap foo bar
    " Execute 'bar'.
    normal foo

    call foo_nmap.restore()
    " Execute 'blahblahblah'.
    normal foo


Omit 2nd arg of |savemap#save_map()| to save all mappings of the mode.
>
    let normal_mappings = savemap#save_map('n')
    if empty(normal_mappings)
        echoerr 'your vim version is lower than 7.3.032!'
    endif

   " Clear!
    nmapclear

    " Map own mappings.
    nnoremap a b
    nnoremap c d
    ...

    try
        ... " Do it
    finally
        call normal_mappings.restore()
    endtry
 
install details
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
savemap.zip 0.2.0 2011-02-19 7.0 tyru - change the specification of |savemap#save_map()|, |savemap#save_abbr()|.
- Even if {lhs} was omitted, Returns |Dictionary| not |List|.
- fix the bug ignoring a non-<buffer> mapping when a <buffer> mapping exists with same lhs-es.
- improve |savemap#save_map()| and |savemap#save_abbr()|.
- you can filter mappings you want by following conditions:
- lhs (literaly, regexp)
- rhs (literaly, regexp)
- <silent>
- remap
- <expr>
- <buffer>
- modes
- add some methods of the return value of
  |savemap#save_map()| and |savemap#save_abbr()|.
- see |savemap-restore-object| for details.
- change the license.
savemap.zip 0.0.0 2010-11-07 7.3 tyru Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github