我正在使用Commentary。它定义了以下键绑定:
command! -range -bar Commentary call s:go(<line1>,<line2>)
xnoremap <expr> <Plug>Commentary <SID>go()
nnoremap <expr> <Plug>Commentary <SID>go()
nnoremap <expr> <Plug>CommentaryLine <SID>go() . '_'
onoremap <silent> <Plug>Commentary :<C-U>call <SID>textobject(get(v:, 'operator', '') ==# 'c')<CR>
nnoremap <silent> <Plug>ChangeCommentary c:<C-U>call <SID>textobject(1)<CR>
nmap <silent> <Plug>CommentaryUndo :echoerr "Change your <Plug>CommentaryUndo map to <Plug>Commentary<Plug>Commentary"<CR>
if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
xmap gc <Plug>Commentary
nmap gc <Plug>Commentary
omap gc <Plug>Commentary
nmap gcc <Plug>CommentaryLine " <-------------------- I WANT TO REBIND THIS
if maparg('c','n') ==# '' && !exists('v:operator')
nmap cgc <Plug>ChangeCommentary
endif
nmap gcu <Plug>Commentary<Plug>Commentary
endif
为了保持我的肌肉记忆在Vim和Emacs之间兼容,我想将gcc
映射到M-;
,因为这是我的Emacs绑定评论切换。但我无法弄清楚如何做到这一点,因为CommentaryLine
没有曝光。意思是我不能用“迷你缓冲器”中的:
来调用它(Vim中的名字?)。
如何映射仅通过预定义键绑定可供用户访问的此类未公开函数?
“插件”映射允许插件作者为他们的插件创建尽可能多的映射,而不会干扰用户自己的映射:
<Plug>Whatever
,在这种情况下,作者创建了许多插件映射(<Plug>CommentaryLine
,<Plug>Commentary
等)并将它们映射到无害的密钥序列(gc
,gcc
等,默认情况下在Vim中没有做任何事情),检查它们是否是尚未映射到别的东西。
但我无法弄清楚如何做到这一点,因为
CommentaryLine
没有曝光。意思是我不能用“迷你缓冲器”中的:
来调用它(Vim中的名字?)。
好吧,开始时没有CommentaryLine
命令或功能,因此您很难在任何地方找到它或从命令行调用它(这是您的“迷你缓冲区”的名称)。
如何映射仅通过预定义键绑定可供用户访问的此类未公开函数?
再次,CommentaryLine
比未曝光更糟糕;它不存在!
nmap gcc <Plug>CommentaryLine " <-------------------- I WANT TO REBIND THIS
你试过以下吗?
nmap <key> <Plug>CommentaryLine
见:help <Plug>
。