[英]To remap Ctrl-c to Ctrl-q is not working in input mode
When I try to call ReplaceIt(), I can type ctrl-c to quit input. 当我尝试调用ReplaceIt()时,我可以输入ctrl-c来退出输入。
function! ReplaceIt()
call inputsave()
let replacement = input('Enter replacement:')
call inputrestore()
execute '%s//'.replacement.'/g'
endfunction
But I have already map Ctrl-c to <Esc><Esc>, I need to remap other key to Ctrl-c before that. 但我已经将Ctrl-c映射到<Esc> <Esc>,我需要在此之前将其他键重新映射到Ctrl-c。
I try to set map <Cq> <Cc>
. 我尝试设置
map <Cq> <Cc>
。 This seting is no use while typing. 这种打字在打字时没用。
Is there any better way to remap key or to quit input? 有没有更好的方法来重新映射密钥或退出输入?
The mode while in input()
is command-line mode (ie :cmap
). 在
input()
中的模式是命令行模式 (即:cmap
)。 Even an unmapped <CC>
will cause input()
to return the empty string, so you should probably check for that ( if empty(replacement)
) and abort your function. 即使未映射的
<CC>
也会导致input()
返回空字符串,因此您应该检查它( if empty(replacement)
)并中止您的函数。
However, I would solve this without explicit input()
(which is not efficient and has problems when recalled in a macro): 但是,我会在没有显式
input()
情况下解决这个问题(在宏中调用时效率不高并且有问题):
:nnoremap <Leader>r :%s///g<Left><Left>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.