2013-08-18 57 views
0

我重新映射了一个键以捕获键被按下,并调用一个函数,在该函数中决定调用一个动作或调用该键,因为此重映射不存在。但问题是,当我重新映射密钥时,我失去了映射到该密钥的操作。在vim中保存以前的映射

热我可以在vimscript中实现这个?

+0

我不知道你所说的“这个重映射不存在”的意思;你试图解决的实际问题是什么?无论哪种方式,这听起来像你需要[':normal!'](http://vimdoc.sourceforge.net/htmldoc/various.html#:normal),也许[':execute'](http:// vimdoc。 sourceforge.net/htmldoc/eval.html#:execute)。 –

回答

1

您可以在函数中使用:h :normal来重新创建您重新映射的密钥的原始功能。例如...

nnoremap l :call MyFun()<cr> 

fun! MyFun() 
    call inputsave() 
    let choice = confirm("Call fun?", "&yes\n&no", 1) 
    if choice == 1 
     call OtherFun() 
    else 
     norm! l 
    endif 
endfun 

fun! OtherFun() 
    echo "It worked!" 
endfun