How to debug vim mapping overlaps?

跟風遠走 提交于 2019-12-06 23:38:20

问题


In general how to debug and solve key bindings overlapping? I had this problem.. Recently I add vim-latex plugin to my vim dir. After that I noticed that my ctrl-j bind is overlapped by vim-latex/plugin/imaps.vim and lost a lot of time until solved that.

By the way: there is a bug in imaps.vim i think, because there is written " map only if there is no mapping already" and my example shows opposite.


回答1:


You can get fine-grained info from the :map command:

To show only mappings relevant to a particular key (in this case ctrl-J):

:map <c-j>

or, better, to show mappings for particular key as well as the script where the mapping was set:

:verbose map <c-j>



回答2:


It is the addition to other people’s answers, not the answer itself.

By the way: there is a bug in imaps.vim i think, because there is written " map only if there is no mapping already" and my example shows opposite.

You are mistaking what «mapping» here means. If you take a look at the code of imaps.vim you’ll see that it won’t create a mapping if there is a mapping to <Plug>IMAP_JumpForward ({rhs}), not if there is a <C-j> mapping ({lhs}). Thus you should use

nnoremap <SID>I_won’t_ever_type_this <Plug>IMAP_JumpForward

in order to disable <C-j> remapping if you don’t need it (of course you could replace <SID>... part with something more meaningful if you do want to use this functionality).




回答3:


:map

Shows a list of your current maps.



来源:https://stackoverflow.com/questions/8546495/how-to-debug-vim-mapping-overlaps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!