简体   繁体   中英

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. I have to resource my vimrc file again for it to work as expected.

I'm using Pathogen for sourcing plugins, which are all contained in my ~/.vim/bundle folder.

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/. 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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