vimdiff but each file on a different tab
Go to file
2022-12-10 19:43:02 -05:00
LICENSE Add README and LICENSE 2022-12-07 18:04:27 -05:00
README.md update README formatting 2022-12-10 19:43:02 -05:00
vimtabdiff.py update README 2022-12-10 19:40:11 -05:00

Do you use git difftool to review changes before making a commit? The problem with that is that you get to see the diff of one file at a time. You can't easily stop it after few files and you can't go back to a previous file. vimtabdiff.py loads all the files with diffs, one in each vim tab page. You can move around any file and edit the diffs easily.

Install

mkdir -p ~/bin

# for python version >= 3.10
curl -o ~/bin/vimtabdiff.py "https://raw.githubusercontent.com/balki/vimtabdiff/master/vimtabdiff.py"

# for python version < 3.10
curl -o ~/bin/vimtabdiff.py "https://raw.githubusercontent.com/balki/vimtabdiff/py38/vimtabdiff.py"

chmod +x ~/bin/vimtabdiff.py

You may need to add ~/bin to your PATH variable if not already done. See here for help. 👍 this issue for pip install support

Screenshot

image

Usage

    usage: vimtabdiff.py [-h] [--vim VIM] pathA pathB

    Show diff of files from two directories in vim tabs

    positional arguments:
      pathA
      pathB

    options:
      -h, --help  show this help message and exit
      --vim VIM   vim command to run

Relevant vim tips

  • gt → Go to next tab
  • gT → Go to previous tab
  • :tabr → Go to first tab
  • :drop filenam<Tab> → Go to the tab with filename
  • g<Tab> → Go to last used tab (Works in vim version > 8.2.1401)
  • set mouse → Now clicking on a tab works
  • ]c → Go to next diff hunk
  • [c → Go to previous diff hunk
  • do, dp → Diff obtain, Diff put
  • zo, zc, zR → Fold open, Fold close, open all folds

See Git diffs

Setup

    git config --global difftool.vimtabdiff.cmd 'vimtabdiff.py $LOCAL $REMOTE'
    git config --global alias.dt 'difftool --tool vimtabdiff --dir-diff'

Usage

    git dt <any git diff revision expression> # see `man gitrevisions`
    git dt           # Unstaged changes
    git dt --staged  # Staged changes
    git dt HEAD~1    # Last commit
    git di v1.0 v2.0 # diff between two tags

Using custom vim command

    git config --global difftool.vimtabdiff.cmd 'vimtabdiff.py --vim "vim --clean" $LOCAL $REMOTE'

Git config file (~/.gitconfig) should look like this

    [alias]
            ...
            dt = difftool --tool vimtabdiff --dir-diff
    [difftool "vimtabdiff"]
            cmd = vimtabdiff.py --vim \"vim --clean\" $LOCAL $REMOTE

Known issues

  1. If your path to vim has a space, it does not work, i.e. Following does not work

    git config difftool.vimtabdiff.cmd 'vimtabdiff.py --vim "/home/foo/my program files/bin/vim" $LOCAL $REMOTE'
    
  2. Not tested in non-linux OS. Pull requests welcome if found any issues but hopefully should work fine.

Similar

https://gist.github.com/Osse/4709787