2

I want to get only output of git diff of whole repository, not just a file, in a tab, Not Split With The Commit Message!

In the issues I found a:

command GdiffInTab tabedit %|Gdiff

But this one opens an split view with commit message, the thing I want is to show only git diff in new tab when editing git commit message. Is it possible? Or should I try doing it myself, something like:

function GitDiffTab()
  exe "tab new %"
  exe "%!git diff"
  exe "se ft=diff"
endfunction

But it doesn't work when editing commit message.

BladeMight
  • 2,670
  • 2
  • 21
  • 35

1 Answers1

3

Use :terminal (requires Vim 8.1+)

:-tab terminal git --no-pager diff

Using fugitive.vim we can create a command:

command! -bang Tdiff execute '-tab terminal ' . call(fugitive#buffer().repo().git_command, ['--no-pager', 'diff'] + (<bang>0 ? ['--cached'] : []))

Use :Tdiff to do git diff and :Tdiff! to do git diff --cached

For more help see:

:h :tab
:h :terminal
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
  • Unfortunately this command didn't work in COMMIT_EDITMSG, just outputs empty tab. However when editing other files of repository it works +1. – BladeMight Jan 31 '19 at 05:02
  • 1
    If you are using fugitive for your commits then you can do `:Gcommit -v` or use `cvc` from the `:Gstatus` window to bring up a verbose commit – Peter Rincker Jan 31 '19 at 05:04
  • Yes that is good solution, but I'd like to see all commit changes in a tab, and another tab for commit message. – BladeMight Jan 31 '19 at 08:09