Skip to content
Ilya Grigoriev edited this page Feb 5, 2024 · 10 revisions

Using Vim as a diff tool

vimdiff comes as a pre-configured merge tool for jj and can be used with jj resolve out of the box. However, the default configuration for vimdiff as a diff editor (for jj split, etc.) is barely useable.

To more conveniently use Vim as a difftool for jj, try one of the following setups:

DirDiff plugin

  1. Install the DirDiff Vim plugin.

  2. Create a script in your PATH named vimdirdiff, with the following contents:

#!/bin/bash
# On Mac OS, you may need to replace `/bin/bash` with `/bin/zsh`.

# Shell-escape each path:
DIR1=$(printf '%q' "$1"); shift
DIR2=$(printf '%q' "$1"); shift
# The colorscheme is only important on Vim versions older than 9.0
vim "$@" -c "colorscheme murphy | DirDiff $DIR1 $DIR2"
  1. Make that script executable: chmod +x vimdirdiff.
  2. In your .jjconfig.toml, set ui.diff-editor="vimdirdiff".

vimtabdiff.py script

  1. Make sure you have Python installed. Optionally, check your Python version by running python --version.

  2. Install vimtabdiff.py as described here. Use the command for python <3.10 if you are not sure what your version of Python is.

    Make sure it is in your PATH and that you ran chmod +x on it.

  3. In your .jjconfig.toml, set ui.diff-editor="vimtabdiff.py".

Pros and cons of DirDiff/vimtabdiff.py

  • The UI if DirDiff is better if you have many files to compare, while the vimtabdiff.py is better for fewer files
  • vimtabdiff.py requires having Python installed, while DirDiff doesn't.
  • DirDiff requires installing a Vim plugin, while vimtabdiff.py doesn't.

Syntax highlighting for editing commit descriptions

The vim-jjdescription Vim plugin provides highlighting of .jjdescription files that jj uses to edit commit messages.

Clone this wiki locally