How do I unmap only when a mapping exists in Vim -
as follow-on accepted answer in how override gf vim-rails, editing same file multiple times results in following error:
error detected while processing user auto commands "rails.javascript.coffee*": e31 : no such mapping
the offending line in vimrc
is
:autocmd user rails.javascript.coffee* nunmap <buffer> gf
how can avoid error unmapping if mapping exists?
(note: editing same file multiple times may seem strange thing do, believe happens side effect of searching ack.vim or ag.vim)
you check mapping if ! empty(maparg('gf', 'n')) ...
, usual solution suppress error prepending silent!
before nunmap <buffer> gf
command.