简体   繁体   English

VIM禁用插件的插入映射

[英]VIM Disable insert mappings of plugins

A plugin adds to my insert mappings a mapping for <leader>is . 一个插件将<leader>is的映射添加到我的插入映射<leader>is I have some ideas which one it can be. 我有一些想法可以。 But it does not matter I don't want to change anything in foreign plugins. 但这并不重要,我不想更改外部插件中的任何内容。 So I want to disable this mapping. 所以我想禁用此映射。 I tried this: 我尝试了这个:

imap <leader>is  <nop>

I did not help. 我没有帮助。

What is your suggestions? 您有什么建议?

BTW, I want to ask how disable in vimrc all insert mapping of plugins? 顺便说一句,我想问一下如何在vimrc中禁用所有插件的插入映射?

To remove an insert mode mapping, use the :iunmap command: 要删除插入模式映射,请使用:iunmap命令:

:iunmap <Leader>is

I don't know whether it is possible to do "bulk unmapping", but at least you can list all active insert mode mappings with 我不知道是否可以进行“批量取消映射”,但是至少您可以列出所有活动的插入模式映射

:imap

or, even better, with 或者,甚至更好

:verbose imap

which will also tell you where the mapping has been defined in the first place. 这也将告诉您首先在哪里定义了映射。


Edit: To clarify, the unmapping needs to be done after the plugin has been loaded. 编辑:为澄清起见,需要在插件加载完成取消映射。 To do so, create a file with the following contents in ~/.vim/after/plugin/ (see @ZyX's answer): 为此,请在~/.vim/after/plugin/创建一个包含以下内容的文件(请参见@ZyX的答案):

" myafter.vim: will be executed after plugins have been loaded
iunmap <Leader>is

Your command if inserted in the vimrc is executed before plugin defines the intrusive mapping and this is why it has no effect. 您的命令(如果插入vimrc中)是在插件定义侵入式映射之前执行的,这就是为什么它无效的原因。 To make it have effect you should make it run after that plugin which is normally achieved either by putting it into ~/.vim/after/plugin/disable_mappings.vim (any name instead of disable_mappings works). 为了使它生效,您应该使它在该插件之后运行,通常可以通过将其放入~/.vim/after/plugin/disable_mappings.vim (使用任何名称代替disable_mappings均可)。 Second is using VimEnter event: 其次是使用VimEnter事件:

augroup DisableMappings
    autocmd! VimEnter * :inoremap <leader>ic <Nop>
augroup END

. To disable all mappings see :h 'paste' and :h 'pastetoggle' , also :h :imapclear (though the latter will remove mappings instead of temporary disabling them). 要禁用所有映射,请参见:h 'paste' :h 'pastetoggle' :h 'paste':h 'pastetoggle'以及:h :imapclear (尽管后者将删除映射而不是暂时禁用它们)。


Of course, you may also use iunmap just where I suggested to use inoremap … <Nop> . 当然,你也可以使用iunmap只是,我建议使用inoremap … <Nop> How did I came to forget this command? 我是怎么忘记了这个命令的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM