Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM Disable insert mappings of plugins

Tags:

vim

mapping

A plugin adds to my insert mappings a mapping for <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?

like image 526
user14416 Avatar asked Nov 22 '12 15:11

user14416


2 Answers

To remove an insert mode mapping, use the :iunmap command:

: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):

" myafter.vim: will be executed after plugins have been loaded
iunmap <Leader>is
like image 88
glts Avatar answered Oct 22 '22 07:10

glts


Your command if inserted in the vimrc is executed before plugin defines the intrusive mapping and this is why it has no effect. 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). Second is using VimEnter event:

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


Of course, you may also use iunmap just where I suggested to use inoremap … <Nop>. How did I came to forget this command?

like image 24
ZyX Avatar answered Oct 22 '22 08:10

ZyX