如何在 Vim 中追捕恶意键绑定
How to hunt down a rogue keybind in Vim
每当我启动 vim 时,键 Y
上都有一个神秘的键绑定,它会破坏常规的 yank 功能。在 :map
的输出中,它看起来像这样:
n Y * y$
我应该可以通过输入 :verbose :map
来查看它的来源,但令我非常沮丧的是,这是整个输出中的 only 键映射无来源:
...
n ) (ale_next_wrap)
Last set from ~/Dropbox/Config/nvim/init_keybinds.lua
v * * "sy/sgn
Last set from ~/Dropbox/Config/nvim/init_keybinds.lua
x S VSurround
Last set from ~/.local/share/nvim/bundle/vim-surround/plugin/surround.vim line 608
n Y * y$
o [% (MatchitOperationMultiBackward)
Last set from /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim line 75
x [% (MatchitVisualMultiBackward)
Last set from /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim line 73
n [% (MatchitNormalMultiBackward)
Last set from /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim line 71
...
那么,在找到罪魁祸首之前,除了一个一个地禁用我的插件之外,还有什么办法可以进一步解决这个键绑定的起源问题吗?
我猜一定是 Neovim-0.6。无论好坏,它几乎没有 :h default-mappings
内置。就个人而言,我只是尽快杀死他们:
" disable default-mappings
if has('nvim-0.6.0')
silent! nunmap Y
silent! nunmap <C-L>
silent! iunmap <C-U>
silent! iunmap <C-W>
endif
每当我启动 vim 时,键 Y
上都有一个神秘的键绑定,它会破坏常规的 yank 功能。在 :map
的输出中,它看起来像这样:
n Y * y$
我应该可以通过输入 :verbose :map
来查看它的来源,但令我非常沮丧的是,这是整个输出中的 only 键映射无来源:
... n ) (ale_next_wrap) Last set from ~/Dropbox/Config/nvim/init_keybinds.lua v * * "sy/sgn Last set from ~/Dropbox/Config/nvim/init_keybinds.lua x S VSurround Last set from ~/.local/share/nvim/bundle/vim-surround/plugin/surround.vim line 608 n Y * y$ o [% (MatchitOperationMultiBackward) Last set from /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim line 75 x [% (MatchitVisualMultiBackward) Last set from /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim line 73 n [% (MatchitNormalMultiBackward) Last set from /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim line 71 ...
那么,在找到罪魁祸首之前,除了一个一个地禁用我的插件之外,还有什么办法可以进一步解决这个键绑定的起源问题吗?
我猜一定是 Neovim-0.6。无论好坏,它几乎没有 :h default-mappings
内置。就个人而言,我只是尽快杀死他们:
" disable default-mappings
if has('nvim-0.6.0')
silent! nunmap Y
silent! nunmap <C-L>
silent! iunmap <C-U>
silent! iunmap <C-W>
endif