问题描述
在安装 vim-ruby-debugger 后,该插件会劫持"一些映射.像<leader>n
或<leader>t
,分别用于NERDTreeToggle和Command-T查找.
After installing vim-ruby-debugger that plugin "hijacks" several mappings. Like <leader>n
, or <leader>t
which I use for respectively NERDTreeToggle and Command-T find.
罪魁祸首位于此ruby-debugger中的硬编码映射.
我希望将它们重新映射为<leader>rdX
,即:以* r * uby- * d * ebugger开头.显然,我可以简单地修改插件并在那里更改映射.但这似乎有点骇人听闻(可能会在更新时中断).
I'd prefer to have these remapped as <leader>rdX
, i.e.: prefixed with *r*uby-*d*ebugger. Obviously, I could simply hack the plugin and change the mappings there. But that seems a bit too hackish (and will probably break on updates).
如何取消这些映射的映射,所以vim将再次回退到我自己的映射?这样我就可以重新映射.vimrc中的命令了(应该是恕我直言).
How can I unmap these mappings, so vim will fallback to my own mappings again? And so that I can remap the commands in my .vimrc (where it should be, IMHO).
推荐答案
首先,我同意ZyX的评论,即这是应解决的插件问题.请要求插件作者提供自定义.
First, I agree with ZyX's comments that this is a problem in the plugin that should be fixed. Please ask the plugin author to provide customization.
没有简单的方法可以取消映射,因为当映射被覆盖时,Vim不会记住原始的映射.您必须记下原始映射(临时禁用有问题的插件时为:map ...
,或在Vim脚本中查找其定义),然后在有问题的插件具有 之后重新执行它们已被加载(减去它可能具有的任何<unique>
标志,因为这些标志会在重新执行时导致错误).这不能在.vimrc
中完成,它首先被获取.我会为此推荐一个类似~/.vim/after/plugin/zzzmappings.vim
的地方.
There is no easy way to unmap, because Vim does not remember the original mappings when a mapping is overridden. You have to make a note of the original mappings (:map ...
when the offending plugin is temporarily disabled, or look in the Vim script for their definitions), then re-execute them after the offending plugin has been loaded (minus any <unique>
flags it may have, as these will cause errors on re-execution). This cannot be done in .vimrc
, it is sourced first; I would recommend a place like ~/.vim/after/plugin/zzzmappings.vim
for this.
这篇关于覆盖来自插件的重新映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!