ok/jj
1
0
Fork 0
forked from mirrors/jj

Instructions and better config for Vim as a diff editor

After I changed `merge-tools.vimdiff.program` to `vim`, using
`vimdiff` as a diff editor wouldn't work at all. 

Out of the box, it's still not a good experience. I included a
recommendation of a plugin to install to make it better.
This commit is contained in:
Ilya Grigoriev 2022-12-17 16:36:15 -08:00
parent 90ba55bd7b
commit 8f9cc3f4e8
2 changed files with 14 additions and 4 deletions

View file

@ -100,10 +100,6 @@ directories to diff are passed as the first and second argument respectively.
For example:
ui.diff-editor = "vimdiff"
When kdiff3 is set via:
ui.diff-editor = "kdiff3"
Custom arguments can be added, and will be inserted before the paths
@ -112,6 +108,14 @@ to diff:
# merge-tools.kdiff3.program = "kdiff3" # Defaults to the name of the tool if not specified
merge-tools.kdiff3.edit-args = ["--merge", "--cs", "CreateBakFiles=0"]
### Using Vim as a diff editor
Using `ui.diff-editor = "vimdiff"` is possible but not recommended.
For a better experience, you can follow these [instructions] to
configure the [`DirDiff` Vim plugin].
[instructions]: https://gist.github.com/ilyagr/5d6339fb7dac5e7ab06fe1561ec62d45
[`DirDiff` Vim plugin]: https://github.com/will133/vim-dirdiff
## 3-way merge tools for conflict resolution

View file

@ -8,6 +8,12 @@ merge-args = ["$left", "$base", "$right", "-o", "$output", "--auto-merge"]
[merge-tools.vimdiff]
program = "vim"
# `-d` enables diff mode. `-f` makes vim run in foreground even if it starts a GUI.
# The other options make sure that only the output file can be modified.
merge-args = ["-f", "-d", "$output", "-M", "$left", "$base", "$right",
"-c", "wincmd J", "-c", "set modifiable", "-c", "set write"]
merge-tool-edits-conflict-markers = true
# Using vimdiff as a diff editor is not recommended. For instructions on configuring
# the DirDiff Vim plugin for a better experience, see
# https://gist.github.com/ilyagr/5d6339fb7dac5e7ab06fe1561ec62d45
edit-args = ["-f", "-d"]