4

I'm using the vim-fugitive plugin for git blame annotations.

When I'm on a certain line, I type :Gblame and it shows me the git commits:

enter image description here

When I click on a git commit hash, I go to it, how can go back to the original view?

Bonus: how can I make the git hash appear on a split view instead of jumping to it?

5

You can use the jump list to go back to your file: pressing ctrlo will bring you back to the top of the commit file and pressing it a second time will bring you back to the file you were editing. (see :h CTRL-O and :h jumplist)

To open the commit in a split window :h fugitive-:Gblame tells you that you can use o when you are on the commit line. You can also use shifto to open it in a new tab.

Note: Instead of clicking on the commit hash you can also use Enter to go to the commit message.

| improve this answer | |
1

Update: I read "original view" in the question as referring to the git blame view. If instead it is meant to refer to the source code file, then @statox's answer is the correct one.

I don't think fugitive provides a mechanism for going back to the previous blame view.

If you make a note of the buffer number before you jump to the commit (with commands such as :ls! or :echo bufnr("")), then you can jump back to it by passing a count to the :b command, but fugitive's mappings no longer appear to be set up.

You can make the hash appear in a split view instead of jumping to it by pressing o instead of Enter. (See :help :Gblame.)

| improve this answer | |
0

I would suggest you use o or O to open commit in a split or net tab. That way the blame is still there and you can use it as a reference.

You can use g? to see :Gblame's help or go to :h fugitive-:Gblame

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.