Enhance fugitive.vim with easy, interactive diff browsing.
Sometimes it can be useful to rapidly explore the differences between versions of a file in your Git repository. I refer to this as scrubbing the diff, just as one would scrub video or audio playback. Unfortunately such interactivity is awkward in Vim.
Manhunt makes it easy to rapidly diff a file against versions of itself.
Only supports vim-fugitive
up to version 2.5. Versions 3.0 and later
break this plugin.
Install via your Vim package manager of choice, and then pin vim-fugitive
to
Git revision 2564c37d0a2ade327d6381fef42d84d9fad1d057
. For Vundle:
Plugin 'arkwright/vim-manhunt'
Plugin 'tpope/vim-fugitive', { 'pinned': 1 } " 2564c37d0a2ade327d6381fef42d84d9fad1d057
There is a swap file problem in gVim for Windows 7 which triggers an E303
error. The solution is to add :set dir=$TEMP
to your _vimrc
file, as per
these instructions:
http://choorucode.com/2010/01/14/vim-unable-to-open-swap-file/
There is also a diff problem with gVim 7.4 on Windows 7, which will trigger
E810
and E97
errors. Here is a fix that seems to work:
http://superuser.com/questions/697847/cant-run-vimdiff-7-4-on-windows-7
Open any file in your Git repo, and execute:
:Manhunt
Three split windows will be created: two diffed versions of the file at the top, and a list of all versions of the file at the bottom (the Version List).
+------------------------------+
| | |
| Recent | Old |
| Version | Version |
| (Diff) | (Diff) |
| | |
+------------------------------+
| Version List |
+------------------------------+
From within the Version List window, use the j
and k
to browse the diff
view in comfort and style! Use ]c
and [c
from within the Version List
window to easily step through the file differences in the splits above.
The Version List window contents are based on the output of :Glog
, but
modified to display additional information, such as the commit date, time, and
author.
Use the :Manhunt
command to turn Manhunt off when you are finished.
Manhunt can operate in three different modes: working
, pair
, and pin
.
You can switch between the three modes at any time, or start Manhunt in a
specific mode, by passing a mode to the :Manhunt
command, like so:
:Manhunt working
:Manhunt pair
:Manhunt pin
working
mode is Manhunt's default mode.
working
mode places the working copy of the file in the left diff split, and
the selected version of your file in the right diff split. The Version List
appears in a bottom split, and contains all versions of the file, with the
most recent version at the top.
This mode makes it easy to diff what you are working on against any arbitrary
version of the same file. This mode also makes it possible to pull changes
into the working version of the file using :diffget
.
pair
mode places the selected version of the file in the left diff split,
and the previous version of the same file in the right diff split. If there is
no previous version of the file, the same version appears in both splits. The
Version List window appears in a bottom split, and contains all versions of
the file, with the most recent version at the top.
This mode makes it easy to step through the differences between two sequential versions of the same file. You can also easily scrub through all individual changes to the file over time, which is great when diffing two distant versions of the same file produces a lot of noise.
Protip: hammer on j
and ]c
mappings from within the Version List window
to step backwards through each change made to the file over time.
pin
mode allows you to select arbitrary versions of the file for display in
the left or right diff split. The Version List window appears in a bottom
split, and contains all versions of the file, with the most recent version at
the top. Within the Version List window, use the L
and R
mappings to
select a version intended the left or right diff split, respectively. (Manhunt
will display an error if you attempt to place the older of the two selected
versions in the left split, or vice versa.)
This mode makes it easy to show the changes to a file within a historical date range, and effortlessly adjust the desired range.
Manhunt provides mappings within the Version List window which make it very
easy to browse the diff splits. By default, you'll be using j
, k
, and
<CR>
to browse versions of the file (L
and R
in pin mode); ]c
, and
[c
to browse differences between the currently diffed versions of the file.
See :help manhunt-mappings
for more information.
Manhunt allows for customization of default key bindings, invocation command name, default mode, and diff auto-alignment method.
See :help manhunt-configuration
for available options.
Probably lots.
Please open a Github issue if you notice something is amiss.
Pull requests, feature requests, ideas, bug reports, etc., are all welcome.
Uses Semantic Versioning.
0.3.1 (2014-09-01)
- Fix gVim/Windows errors.
0.3.0 (2014-07-05)
- Add a new mode:
pin
mode. - Use a custom buffer, the Version List, instead of the quickfix window.
- Add signs to Version List to indicate the versions being diffed.
- Change
g:manhunt_key_next_diff
andg:manhunt_key_previous_diff
default bindings to be]c
, and[c
, respectively.
0.2.0 (2014-07-01)
- Add commit date, time, and author to quickfix window.
- Scroll and pretty-format the contents of the quickfix window so that it is easier to read.
0.1.0 (2014-06-29)
- Create
:Manhunt
command with two basic modes:working
andpair
.
Manhunt is lovingly crafted by Robert Arkwright.
Manhunt is but a tiny feature added to Tim Pope's amazing fugitive.vim.
This plugin would not have been possible without Steve Losh's incredible book: Learn Vimscript the Hard Way.