1

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?

2
  • 2
    You can always check to see if the filename starts with fugitive://. That should give you a pretty good idea that this was opened with fugitive. However you might want to map q to :close so you don't accidentally quit vim if it is the only window. Commented Jul 13, 2017 at 21:21
  • @PeterRincker Thats a good idea. I noticed some code in fugitive itself that uses this sort of check: 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 to set modifiable and intentionally change the contents of the git object, in which case I'd prefer it did complain.
    – ivan
    Commented Jul 14, 2017 at 12:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.