Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overwrite conflicting mappings silently in .vimrc

Tags:

vim

I have a mapping in .vimrc that conflicts with another mapping in a plugin.

nnoremap <leader>p some fancy command here

When I run VIM, I get a warning:

E227: mapping already exists for ,p

How to overwrite the offending mappings silently?

Edit:

  • it neither works with nmap
like image 268
Jakub M. Avatar asked Oct 31 '13 10:10

Jakub M.


1 Answers

This might squelch the warning:

:nnoremap <silent> <leader>p some fancy command here

But I suspect the warning isn't actually coming from your mapping. I suspect that the conflicting mapping is defined with <unique>, and is being mapped after your mapping. <unique> will issue an E227 if a conflicting map already exists. See :h E227.

Dig around for a second source of the mapping (plugin, probably) and see if that's the case. Most well-written plugins offer you a way to use your own mappings or overwrite theirs, by setting a global flag to disable mappings entirely, or will detect that you've mapped something else to a specific function (via hasmapto)

You can see which plugin/script set a mapping via:

:verbose map <leader>p

That should help track down the source.

like image 91
Jim Stewart Avatar answered Oct 30 '22 02:10

Jim Stewart