I use vundle and some other plugins for Vim
When I execute :map <F5>
I see <F5> :!ruby %<CR>
But I have defined in the end of my ~/.vimrc
after all Bundle
instuctions these mappings:
imap <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
nmap <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
omap <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
cmap <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
vmap <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
smap <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
xmap <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
map <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
Also if I execute in Vim :map <F5> <Esc><Esc>:w<CR>:!ruby %<CR>
it works the way it should. Seems like my mappings in .vimrc are ignored.
Why is that? How to remap <F5>
?
UPDATE:
:verbose map <F5>
<F5> :!ruby %<CR>
Last set from ~/Dropbox/home/.vim/bundle/ruby-menu.vim/plugin/ruby-menu.vim
Actually I don't need ruby-menu plugin, gonna trash it. Btw, why does it remap my mappings?
You can check where this got defined via
It seems to be from this line in the ruby-menu plugin. That plugin should offer
<Plug>
-mapping targets that would allow you to change the mapped keys, or disable the mapping altogether. You could file a defect against it.The plugin overrides your mapping, because by the time the plugin loads, your .vimrc already has finished processing.
To workaround, you need to define the mapping after the plugin loads, with one of these methods:
~/.vim/bundle/ruby-menu.vim/after/plugin/ruby-menu.vim
~/.vim/after/plugin/mappings-override.vim
) that is sourced after the plugins (check with:scriptnames
)~/.vimrc
viaautocmd VimEnter * map <F5> ...
, thereby delaying the actual definition until after the plugins have been initialized