sponsor Vim development Vim logo Vim Book Ad

ConflictDetection : Detect and highlight SCM conflict markers.

 script karma  Rating 13/4, Downloaded by 2909  Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
utility
 
description
DESCRIPTION
This plugin detects and highlights conflict markers such as <<<<<<<, =======,
and >>>>>>>, which are inserted by source code management systems on merges to
indicate that the automatic resolution failed; this plugin helps you with
becoming aware of and finding them.

RELATED WORKS
To quickly locate and resolve the conflicts, you can use the motions and text
objects provided by the companion ConflictMotions.vim plugin (vimscript
#3991).


USAGE
The plugin automatically adds syntax definitions for the conflict markers and
the conflicted lines which are enclosed in the markers. Lines originating from
"our" version are highlighted in a different way than lines from "their"
version, so it's easier for you to visually differentiate the alternatives and
make the right editing choices to resolve the conflict. The "base" version of
the diff3-style syntax is supported, too.

:ConflictSyntax [{syntax}]
                        Remove / change the syntax (to {syntax}) while keeping
                        the conflict syntax definitions (:setl syntax=...
                        would remove them as well). Useful when the filetype's
                        own syntax interferes with the overlaid conflict
                        syntax definitions.

The plugin warns you when a buffer that contains conflict markers is edited or
saved. Cp. g:ConflictDetection_WarnEvents

The detections stores its status in the buffer variable b:conflicted. You can
evaluate this boolean variable in a custom statusline to indicate whether
the buffer contains conflicts.
 
install details
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim ConflictDetection*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.003 or
  higher.


CONFIGURATION
For a permanent configuration, put the following commands into your vimrc:

By default, the DiffAdd (our version), DiffText (their version), and
DiffChange (base version) highlight groups are used for highlighting
conflicted lines. The lines containing the highlight markers are colored with
a foreground color derived from the correspoding groups.
You may define your own colors via the :highlight command:
    highlight def link conflictOurs                     guibg=Green
    highlight def link conflictBase                     guibg=Brown
    highlight def link conflictTheirs                   guibg=Red
    highlight def link conflictSeparatorMarkerSymbol    guifg=Black
    highlight def conflictOursMarker                    guifg=Green
    highlight def conflictBaseMarker                    guifg=Brown
    highlight def conflictTheirsMarker                  guifg=Red

The buffer is searched for conflict markers when a file is edited and when the
buffer is saved, and the status is updated accordingly. The autocmd-events
are stored in a variable. If you don't need the auto-detection, empty the
event list:
    let g:ConflictDetection_AutoDetectEvents = ''

A warning message is issued when the buffer is read or written and conflict
markers have been detected. You can empty / edit the autocmd-events list if
you don't want a warning at all / on buffer writes only:
    let g:ConflictDetection_WarnEvents = 'BufWritePost'
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ConflictDetection-1.12.vmb.gz 1.12 2013-03-27 7.0 Ingo Karkat - To avoid false positives (e.g. in nested email replies), ensure that both "our" and "theirs" markers do exist.
- Add dependency to ingo-library (vimscript #4433) *** DOWNLOAD AND INSTALL SEPARATELY ***
ConflictDetection-1.11.vmb.gz 1.11 2012-12-04 7.0 Ingo Karkat FIX: Prevent error on Vim 7.0 - 7.2.
ConflictDetection-1.10.vmb.gz 1.10 2012-12-04 7.0 Ingo Karkat ENH: Add :ConflictSyntax command to work around interference of the conflict highlightings with the original filetype's syntax.
ConflictDetection-1.02.vmb.gz 1.02 2012-11-16 7.0 Ingo Karkat FIX: Avoid E417 / E421 in conflict marker highlight group definitions when no original color is defined (i.e. when the colorscheme does not define a cterm / gui background color for DiffAdd/Change/Text). Thanks to Dave Goodell for sending a patch.
ConflictDetection-1.01.vmb.gz 1.01 2012-10-17 7.0 Ingo Karkat Avoid long search delays on very large files.
ConflictDetection.vba.gz 1.00 2012-07-13 7.0 Ingo Karkat Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github