简体   繁体   English

取消映射 Vim 插件映射

[英]Unmapping Vim Plugin mappings

Is there a way to unmap mappings set by plugins?有没有办法取消插件设置的映射? I'm currently calling exe ":mapclear" before my custom mappings in my .vimrc file, but the plugin files appear to be sourced after the vimrc file does.我目前在我的 .vimrc 文件中的自定义映射之前调用exe ":mapclear" ,但插件文件似乎是在 vimrc 文件之后获取的。 I have to resource my vimrc file again for it to work as expected.我必须再次资源我的 vimrc 文件才能按预期工作。

I'm using Pathogen for sourcing plugins, which are all contained in my ~/.vim/bundle folder.我正在使用 Pathogen 来获取插件,这些插件都包含在我的 ~/.vim/bundle 文件夹中。

You could write the part with the mappings in your .vimrc in another file, say MyMaps.vim, and put this file in ~/.vim/after/plugin/.您可以将 .vimrc 中的映射部分写入另一个文件中,例如 MyMaps.vim,并将此文件放在 ~/.vim/after/plugin/ 中。 This should make your maps the default ones这应该使您的地图成为默认地图

Look also at the documentation of the plugins setting the mappings, some of them allow you redifine or deactivate the default mappings.另请查看设置映射的插件文档,其中一些允许您重新定义或停用默认映射。

While snooping around my various plugins, I've found a kind of solution.在窥探我的各种插件的同时,我找到了一种解决方案。

Unfortunately, a lot of the plugins (such as vim-surround, and vim-align, which in turn uses cecutil) add commands to my mapleader.不幸的是,许多插件(例如 vim-surround 和 vim-align,它们又使用 cecutil)向我的 mapleader 添加命令。 Since I realised there actually are some key mappings from plugins I do use, I decided to set my mapleader back to its default (backslash) at the end of my vimrc file to prevent overlap.因为我意识到实际上有一些来自我使用的插件的键映射,我决定在我的 vimrc 文件的末尾将我的 mapleader 设置回它的默认值(反斜杠)以防止重叠。

The only problem I came across were mappings that were set in functions.我遇到的唯一问题是在函数中设置的映射。 When using au FileType html call ConfigHTML() , for example, the ConfigHTML() function would actually get called after the mapleader is set back to backslash.例如,当使用au FileType html call ConfigHTML() ,实际上会在 mapleader 设置回反斜杠后调用ConfigHTML()函数。

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

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