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 870  Comments, bugs, improvements  Vim wiki

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

- 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!'

    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!'

   " Clear!

    " Map own mappings.
    nnoremap a b
    nnoremap c d

        ... " Do it
        call normal_mappings.restore()
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:

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.