3

The command I use to check the project diff is

git diff | vimdiff -

Is there a way I can refresh the diff file without existing Vim and repeating the previous command?

echristopherson
  • 6,974
  • 2
  • 21
  • 31
Nabil Kadimi
  • 10,078
  • 2
  • 51
  • 58
  • 1
    Why would you use `vimdiff` on standard input? `vimdiff` expects two files. You may simply `git diff | vim -` to get the same effect. Anyway, the command `git diff` is already piped; you have to execute it again if you wish to see how it changes. Consider using other vim tools for that purpose. – Bach Feb 18 '14 at 12:38
  • that's simply not true. – Bach Feb 18 '14 at 15:37
  • @HansZauber yes, sorry...withdrawn. – Nabil Kadimi Feb 18 '14 at 16:19

2 Answers2

5

The Vim instance only receives the diff information from stdin (via the | shell pipe), so there's no way to refresh that.

If you don't want to exit Vim and recall the command from the shell history, I would recommend using a plugin (like fugitive.vim - A Git wrapper so awesome, it should be illegal) that allows you to trigger (and re-trigger!) a diff from within Vim.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
3

In Vim:

:%d | .!git diff

The first part deletes all lines, and the second runs git diff in the cwd and pipes the output of this command to the buffer.

DBedrenko
  • 4,871
  • 4
  • 38
  • 73