Get only git diff output in tab

386 views Asked by At

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.

1

There are 1 answers

3
Peter Rincker On

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