When you run fugitive's :Gblame
, it opens a buffer whose 'filetype' is fugitiveblame
. You can hit q
to close its window. You can also hit o
to view the commit for the line your cursor is on in a separate split.
Intuitively, I'd expect to be able to hit q
in this window as well, dismissing the commit view, but no such mapping is provided. I'd like to add one.
The 'filetype' for the commit buffer is git
, and I'm worried there might be other things that use that filetype, so I'm a little hesitant to add a q
mapping to ~/.vim/ftplugin/git.vim
Does anyone know how specific to fugitive the git
'filetype' is?
fugitive://
. That should give you a pretty good idea that this was opened with fugitive. However you might want to mapq
to:close
so you don't accidentally quit vim if it is the only window.expand('%:p') =~# '^fugitive:[\\/][\\/]'
. Also, I went with:bdelete
since it seems like the best fit. If there's only one window, it will change to the previously displayed buffer, if there are multiple windows, it deletes the git buffer and its window. If the buffer is modified, it complains, but to reach that state I'd have toset modifiable
and intentionally change the contents of the git object, in which case I'd prefer it did complain.