3

Using Vim-fugitive plugin I open a commit with

:Gedit HEAD~5

The buffer looks like this:

tree a75d4eea2207e408db6343a4869274b701b42135
parent 7fa89fec125ce60a341f7c37dd769a8a31c49359
author Takahiro Yoshihara <tacahiroy@gmail.com> Tue Feb 21 09:07:51 2017 +0900
committer Takahiro Yoshihara <tacahiroy@gmail.com> Sun Mar 19 18:16:51 2017 +0900

Fix incorrect matching in buffer mode with by_filename (#346)


diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim
index 6558939..05196ae 100644
--- a/autoload/ctrlp.vim
+++ b/autoload/ctrlp.vim
@@ -2384,7 +2384,7 @@ endf
 fu! s:matchbuf(item, pat)
    let bufnr = s:bufnrfilpath(a:item)[0]
    let parts = s:bufparts(bufnr)
-   let item = bufnr.parts[0].parts[2].s:lash().parts[3]
+   let item = s:byfname ? parts[2] : bufnr.parts[0].parts[2].s:lash().parts[3]
    retu match(item, a:pat)
 endf

(the diff part appears folded)

Now putting the cursor on the first line of the diff, I would like to open that diff in a vertical split vim-diff mode like :Gvdiff (in a new tab or in the same tab below the current window) viewing the changes made to the file.

Currently issuing :Gvdiff compares the entire commit-buffer with something weird.

Basically I would like to have the same diff-view, as I get with dv in the :Gstatus window.

My questions are:

  • How can I open the vertical split diff on a selected file?
  • How can I close that view going back to my commit buffer?
1
  • I found, that with the simple ENTER opens the split diff view. But if closes the commit-edit buffer and there seams to be no way to open it again... (I have a mapping in place, that closes inactive fugitive-buffers) Jun 7, 2018 at 9:26

2 Answers 2

5

From :h fugitive-mappings you can use:

  • <cr> to open the diff in the current window
  • o open the diff in a horizontal split
  • O to open the diff in a new tab page
  • S open diff in a vertical split

I imagine you want to use S on the diff line. However as screen space can be a concern with diff-ing, O might be a better option.

1
  • This is exactly, what I have been looking for! o is most useful, I think :) Thank you! Jun 7, 2018 at 14:13
3

I love using vimdiff to compare commits side by side:

git difftool --tool=vimdiff commit_id_01 commit_id_02 path/to/file

Your Answer

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

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