我只想在选项卡中获取整个存储库的 git diff
输出,而不仅仅是一个文件,不与提交消息分开
!
在 issues我发现了一个:
command GdiffInTab tabedit %|Gdiff
但是这个打开了一个包含提交消息的 Split View,我想要的是在编辑 git 提交消息时在新选项卡中仅显示 git diff 。 是否可以?或者我应该尝试自己做,例如:
function GitDiffTab()
exe "tab new %"
exe "%!git diff"
exe "se ft=diff"
endfunction
但编辑提交消息时不起作用。
最佳答案
使用 :terminal
(需要 Vim 8.1+)
:-tab terminal git --no-pager diff
使用fugitive.vim我们可以创建一个命令:
command! -bang Tdiff execute '-tab terminal ' . call(fugitive#buffer().repo().git_command, ['--no-pager', 'diff'] + (<bang>0 ? ['--cached'] : []))
使用 :Tdiff
执行 git diff
和 :Tdiff!
执行 git diff --cached
更多帮助请参见:
:h :tab
:h :terminal
关于git - 仅在选项卡中获取 git diff 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54378200/