So far, I am trying to understand how to use :Glog
in combination with :Gdiff
, to create a nice overview like the git-time-machine plugin for the Atom editor:
The overview exists of 3 windows
When I select a commit from the quickfix list, the version will be placed in the right window. Not to forget the difference being highlighted.
Can someone help me? :)
Modern Vim has a built-in terminal. That means you can always start :term and start using Git command-line interface like you're used to. You can also start a specific command like :term git status or :term git add % (where % refers to the current file path). For simple commands, even simple bang!
Adjective As he daydreamed, fugitive thoughts passed through his mind.
I'm not aware of a plugin that is exactly like that. But there's gitv, which is like gitk for vim.
Even though it's currently not being actively maintained it's working quite well IMHO.
Source
Here are some commands that you can use to simulate a crude version of the behaviour you describe.
:only
to close any other split windows:Glog
to populate the quickfix list with all past revisions of the file:cnext
and :cprev
So far this is basic usage. Now suppose that you find yourself looking at a previous version of the file that you want to diff with the working copy. Here's how you could do that:
:vsplit
to divide your workspace into two split windows<C-w><C-h>
to activate the left split:Gedit
, which loads the working copy version of the file you're looking at:windo diffthis
Boom! You've got a diff with the working copy on the left and the previous version on the right.
Now let's say that you want to keep the working copy in the left split, while traversing through other past versions in the right split:
<C-w><C-l>
to activate the right split:cprev
/:cnext
to go back/forwards through the quickfix list (the right split window will move out of diffmode, but the left split remains in diffmode):diffthis
to activate a diff between the current buffer and the working copyWhen you're done looking at diffs, run:
:diffoff!
to disable diff mode:only
to collapse your workspace into a single split:Gedit
to switch back to the working copy of the file you're working withYou could automate some of these steps using Vimscript, and you could also add the quickfix window at the bottom of the screen the way you suggested. It would make a neat plugin! Personally, I'm happy to run these commands by hand. This workflow looks complicated when written out, but it can become second nature with practice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With