All Projects → whiteinge → Diffconflicts

whiteinge / Diffconflicts

Licence: bsd-3-clause
A better Vimdiff Git mergetool

Projects that are alternatives of or similar to Diffconflicts

vim-opex
Vim operators to execute text objects
Stars: ✭ 19 (-93.4%)
Mutual labels:  vim-plugin
gx-extended.vim
Extend gx to use it beyond just URLs!
Stars: ✭ 23 (-92.01%)
Mutual labels:  vim-plugin
Vim Wintabs
Modern buffer manager for Vim
Stars: ✭ 268 (-6.94%)
Mutual labels:  vim-plugin
fileselect
File Selector Vim Plugin
Stars: ✭ 14 (-95.14%)
Mutual labels:  vim-plugin
vim-highlighter
Highlight words and expressions
Stars: ✭ 57 (-80.21%)
Mutual labels:  vim-plugin
Vim Rubocop
The Vim RuboCop plugin runs RuboCop and displays the results in Vim
Stars: ✭ 262 (-9.03%)
Mutual labels:  vim-plugin
vim-wordy
Uncover usage problems in your writing
Stars: ✭ 677 (+135.07%)
Mutual labels:  vim-plugin
Eleline.vim
🌿 Another elegant statusline for vim
Stars: ✭ 283 (-1.74%)
Mutual labels:  vim-plugin
roast.vim
An HTTP client for Vim, that can also be used as a REST client.
Stars: ✭ 78 (-72.92%)
Mutual labels:  vim-plugin
Vim Cool
A very simple plugin that makes hlsearch more useful.
Stars: ✭ 268 (-6.94%)
Mutual labels:  vim-plugin
vim-hugo-helper
A small Vim plugin with a set of helpers for Hugo https://gohugo.io
Stars: ✭ 82 (-71.53%)
Mutual labels:  vim-plugin
format.nvim
Neovim lua plugin to format the current buffer with external executables
Stars: ✭ 189 (-34.37%)
Mutual labels:  vim-plugin
Jshint2.vim
Lightweight, customizable and functional Vim plugin for JSHint integration.
Stars: ✭ 265 (-7.99%)
Mutual labels:  vim-plugin
cmp-under-comparator
nvim-cmp comparator function for completion items that start with one or more underlines
Stars: ✭ 77 (-73.26%)
Mutual labels:  vim-plugin
Textbeat
🎹 plaintext music sequencer and midi shell, with vim playback 🥁
Stars: ✭ 274 (-4.86%)
Mutual labels:  vim-plugin
vim-docker-tools
Toolkit for managing docker containers in vim.
Stars: ✭ 95 (-67.01%)
Mutual labels:  vim-plugin
Completeparameter.vim
Complete parameter after select the completion. Integration with YouCompleteMe(ycm), deoplete, neocomplete.
Stars: ✭ 258 (-10.42%)
Mutual labels:  vim-plugin
Gen tags.vim
Async plugin for vim and neovim to ease the use of ctags/gtags
Stars: ✭ 288 (+0%)
Mutual labels:  vim-plugin
Vim Monokai Tasty
VIM Colour scheme
Stars: ✭ 279 (-3.12%)
Mutual labels:  vim-plugin
Vaffle.vim
📁 Lightweight, window-based file manager for Vim
Stars: ✭ 269 (-6.6%)
Mutual labels:  vim-plugin

vim-diffconflicts

A better Vimdiff mergetool.

tl;dr:

  • Call :DiffConflicts to convert a file containing conflict markers into a two-way diff.
  • Install as a Git or Mercurial mergetool to do that automatically. (See Installation below.)

Why?

Watch a demonstration version of this README on YouTube:

diffconflicts Video Demonstration

Contents:

Three-Way Diffs are Hard

When Git cannot automatically resolve conflicts it writes a file with conflict markers surrounding the conflicting areas. These conflicts must be resolved manually. This is often done via a three-way comparison.

Vim supports three-way diffs however syntax highlighting alone is not sufficient to showcase the differences between that many versions. In addition, the default keybindings are not well suited to moving individual changes between that many windows.

The screenshot below is an example of Vimdiff as a Git mergetool using default settings. None of the conflicts have an obvious resolution:

Editing Conflict Markers is Hard

When human intervention is needed it is rarely as simple as choosing the "left" change or the "right" change. The correct resolution often involves a mix of both changes. It is difficult to manually edit a file containing Git conflict markers because the human eye isn't well suited to spotting subtle differences, particularly when the differences are not adjacent:

Two-Way Diffs are Eas(ier)

A two-way diff more simply highlights just the relevant differences which makes the resolution more clear. The merge base and history of each version of the conflict is a useful reference to learn the intent of each conflicting change, however those are not as useful to see in the diff.

Vimdiff is well suited to two-way diffs:

Conflict-Markers are a Two-Way Diff

Git does an admirable job of automatically resolving conflicts. We want to retain all the work and resolve only the things that Git could not. That work is reflected in the files containing conflict markers, but it is not reflected in a two-way diff between LOCAL and REMOTE.

Rather than editing the conflict markers directly, it is better to perform a two-way diff on only the "left" and "right" sides of the conflict markers by splitting them apart.

Installation

  1. Install this plugin using your favorite Vim plugin manager, or just clone the repo into your packages directory (see :help packages).

  2. Configure Git to use this plugin as a mergetool:

    git config --global merge.tool diffconflicts
    git config --global mergetool.diffconflicts.cmd 'vim -c DiffConflicts "$MERGED" "$BASE" "$LOCAL" "$REMOTE"'
    git config --global mergetool.diffconflicts.trustExitCode true
    git config --global mergetool.keepBackup false
    

    Or, if you'd prefer to always open both the diff view and the history view call DiffConflictsWithHistory instead:

    git config --global mergetool.diffconflicts.cmd 'vim -c DiffConflictsWithHistory "$MERGED" "$BASE" "$LOCAL" "$REMOTE"'
    
  3. During a merge you can call :DiffConflictsShowHistory to open a new tab containing the merge BASE and full copies of the LOCAL and REMOTE versions of the conflicted file. This can help to understand the history or intent behind the conflicting changes to help you decide how best to combine the changes.

    This tab is not opened by default so that Vim starts more quickly.

Mercurial

Configure Mercurial to use diffconflicts as a mergetool by adding:

[merge-tools]
diffconflicts.executable=vim
diffconflicts.args=-c 'let g:diffconflicts_vcs="hg"' -c DiffConflicts "$output" $base $local $other
diffconflicts.premerge=keep
diffconflicts.check=conflicts
diffconflicts.priority=99

to your .hgrc file. Or, if you prefer to always open both the diff view and the history view use

diffconflicts.args=-c 'let g:diffconflicts_vcs="hg"' -c DiffConflictsWithHistory "$output" $base $local $other

as the args setting to call DiffConflictsWithHistory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].