Best I can tell, all the diff commands in Fugitive open up a split window. Is there a way to just show the added/deleted/modified lines in a single window -- i.e., show the current file's changes (since the last commit, or, ideally, since an arbitrary commit) without opening a window with the index version?
1 Answers
If the unified/inline diff is what you mean by a single window, you can use Fugitive :Git diff @ -- %
command to just show the added/deleted/modified lines of the current file since the last commit in a new single window.
If you are looking for intra-line diff, as the opposite of side-by-side diff, just like VSCode's inline diff view Example (set diffEditor.renderSideBySide
option to false
) or GitHub's Unified diff display Example ... Unfortunately, Vim doesn't support that.
If you only want to show the changes since the last commit, just run :G
command, here is the unified diff format. Otherwise, you can use git's diff
command by Fugitive, just run :G diff BASE_COMMIT
to show the unified/inline diff against an arbitrary commit. For example, :G diff HEAD
, :G diff @~2 -- %
, :G diff f88a3b8
and so on. For details to see git docs (git diff --help
) and fugitive docs (:help fugitive
, :h fugitive-object
).
Is there a way to just show the added/deleted/modified lines in a single window ?
Solution other than fugitive: If you only want to show the unified/inline diff highlighting just in the current window, maybe you need other plugins see IDE-like inline diff highlighting in Vim. About the vim-gitgutter plugin, as for your question, jump to the doc of vimdiff. You can also specify an arbitrary commit to compare against by the g:gitgutter_diff_base
variable (e.g. :let g:gitgutter_diff_base = 'HEAD~2'
). Then you can run :GitGutterFold
command to see the current file's changes without opening any other windows. Now you can use :GitGutterPrevHunk
and :GitGutterNextHunk
to jump between your change hunks, and :GitGutterPreviewHunk
to show the hunk details. Of course, there is also a :GitGutterDiffOrig
command here, just like the Fugitive :Gdiffsplit
command. For convenience, see :help gitgutter-mappings
. For more features and details see it's documentations, it will be helpful to use it with vim-fugitive.

- 471
- 1
- 3
- 7