BladeMight
BladeMight

Reputation: 2810

Get only git diff output in tab

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.

Upvotes: 2

Views: 399

Answers (1)

Peter Rincker
Peter Rincker

Reputation: 45117

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

Upvotes: 3

Related Questions