It seems the mapping is local to a buffer as it was defined with the argument
When you type
:unmap y<C-G>, you ask Vim to unmap a global mapping whose
y<C-G>, but there's probably no such global mapping on your system hence the error.
If you want to unmap the local mapping, you have to use the same argument
<buffer> which was used to define it:
:unmap <buffer> y<C-G>
To automate the process you could install an autocmd watching the events
BufReadPost. It would test if the mapping exists
if !empty(maparg('y<C-G>', 'n')), before trying to delete it. It could give something like:
autocmd VimEnter,BufNewFile,BufReadPost * if !empty(maparg('y<C-G>', 'n')) | unmap <buffer> y<C-G>| endif
You couldn't write this in your
vimrc because the latter is sourced before your plugins which would override anything you do. Instead you would have to write it inside
~/.vim/after/plugin/mappings.vim. The filename (
mappings.vim) doesn't matter, only the directory is important (
As your last comment says it, it seems there's another way to disable the mapping.
fugitive install the mappings
y<C-G> only if
g:fugitive_no_maps is different than zero. So if you include
let g:fugitive_no_maps=1 inside your
y<C-G> should not be defined.