Code Monkey home page Code Monkey logo

savemap.vim's Introduction

|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


See doc/savemap.txt or :help savemap for more details.

savemap.vim's People

Contributors

tyru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

savemap.vim's Issues

usage in other plugin

Hello, your plugin could be useful in the Plugin FastFold to append the command :FastFoldUpdate!<CR> to all mappings that close or open folds such as za,zc,zo,... without overwriting user mappings.

Can the relevant parts of your plugin be copied and then it suffices to refer to your plugin, or does your plugin have to be installed alongside?

Edit: Regarding what the plugin's New BSD license says the first option sounds fine?

Crash when RHS contains a pipe

Hi !

Thanks for that incredibly useful plugin !

The plugin 'crash' when the rhs contains a |.

n  [m          *@:call <SNR>59_Python_jump('n', '\v^\s*(class|def|async def)>', 'Wb')<CR>
n  [[          *@:call <SNR>59_Python_jump('n', '\v^(class|def|async def)>', 'Wb')<CR>
n  ]m          *@:call <SNR>59_Python_jump('n', '\v%$|^\s*(class|def|async def)>', 'W')<CR>
n  ]]          *@:call <SNR>59_Python_jump('n', '\v%$|^(class|def|async def)>', 'W')<CR>

The following

let mappings = savemap#save_map('n')

produce:

Error detected while processing function SubmodesLoaded[39]..savemap#save_map[1]..<SNR>77_save_map[12]..<SNR>77_make_ma
p_info[15]..<SNR>77_restore_map_info:
line   11:
E492: Not an editor command: def|async def)>', 'Wb')<cr>
Error detected while processing function SubmodesLoaded[39]..savemap#save_map[1]..<SNR>77_save_map[12]..<SNR>77_make_ma
p_info[15]..<SNR>77_restore_map_info:
line   11:
E492: Not an editor command: def|async def)>', 'Wb')<cr>
Error detected while processing function SubmodesLoaded[39]..savemap#save_map[1]..<SNR>77_save_map[12]..<SNR>77_make_ma
p_info[15]..<SNR>77_restore_map_info:
line   11:
E492: Not an editor command: ^\s*(class|def|async def)>', 'W')<cr>
Error detected while processing function SubmodesLoaded[39]..savemap#save_map[1]..<SNR>77_save_map[12]..<SNR>77_make_ma
p_info[15]..<SNR>77_restore_map_info:
line   11:
E492: Not an editor command: ^(class|def|async def)>', 'W')<cr>

I fixed the error by duplicating the code that replace | with <bar> for the rhs. (it was a quick and dirty patch, i don't even know if that is the way to solve the issue)

function! s:maparg(...) "{{{
    let info = call('maparg', a:000)
    if has_key(info, 'lhs')
        let info.lhs = substitute(info.lhs, '|', '<Bar>', 'g')
    endif
    if has_key(info, 'rhs')
        let info.rhs = substitute(info.rhs, '|', '<Bar>', 'g')
    endif
    return info
endfunction "}}}

But now the mappings output (even though i didn't clear or restore the mappings)

E117: Unknown function: <SNR>77_Python_jump

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.