Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding a remapping from a plugin?

Tags:

vim

remap

After installing vim-ruby-debugger that plugin "hijacks" several mappings. Like <leader>n, or <leader>t which I use for respectively NERDTreeToggle and Command-T find.

The culprit is found at the hardcoded mappings in this ruby-debugger.

I'd prefer to have these remapped as <leader>rdX, i.e.: prefixed with *r*uby-*d*ebugger. Obviously, I could simply hack the plugin and change the mappings there. But that seems a bit too hackish (and will probably break on updates).

How can I unmap these mappings, so vim will fallback to my own mappings again? And so that I can remap the commands in my .vimrc (where it should be, IMHO).

like image 913
berkes Avatar asked Oct 07 '12 15:10

berkes


1 Answers

First, I agree with ZyX's comments that this is a problem in the plugin that should be fixed. Please ask the plugin author to provide customization.

There is no easy way to unmap, because Vim does not remember the original mappings when a mapping is overridden. You have to make a note of the original mappings (:map ... when the offending plugin is temporarily disabled, or look in the Vim script for their definitions), then re-execute them after the offending plugin has been loaded (minus any <unique> flags it may have, as these will cause errors on re-execution). This cannot be done in .vimrc, it is sourced first; I would recommend a place like ~/.vim/after/plugin/zzzmappings.vim for this.

like image 194
Ingo Karkat Avatar answered Sep 28 '22 00:09

Ingo Karkat