Home

Awesome

conflict-marker.vim

CI Coverage

Highlight, jump and resolve conflict markers quickly.

conflict-marker.vim is Vim plugin for developers fighting against conflicts. All features are available if and only if an opened buffer contains a conflict marker.

conflict-marker.vim does:

This plugin tries to define some mappings if a conflict marker is detected. If you don't want to use default mappings, set g:conflict_marker_enable_mappings to 0.

Installation

Please follow the instruction in :help add-package.

If you use some plugin manager, please follow its instruction and documentation to install. For example, you can install this plugin with neobundle.vim.

NeoBundle 'rhysd/conflict-marker.vim'

Conflict Markers

Conflict markers can be customized using the following options:

" Default values
let g:conflict_marker_begin = '^<<<<<<< \@='
let g:conflict_marker_common_ancestors = '^||||||| .*$'
let g:conflict_marker_separator = '^=======$'
let g:conflict_marker_end   = '^>>>>>>> \@='

Highlight Conflict Markers

Conflict markers are highlighted by default. Use the following option to disable highlighting:

let g:conflict_marker_enable_highlight = 0

Each conflict marker and conflict part is associated to a specific syntax group:

marker / partsyntax group
begin conflict marker (<<<<<<<)ConflictMarkerBegin
ours part of the conflictConflictMarkerOurs
common ancestors marker (|||||||)ConflictMarkerCommonAncestors
common ancestors part of the conflictConflictMarkerCommonAncestorsHunk
separator conflict marker (=======)ConflictMarkerSeparator
theirs part of the conflictConflictMarkerTheirs
end conflict marker (>>>>>>>)ConflictMarkerEnd

By default, ConflictMarkerBegin, ConflictMarkerSeparator, ConflictMarkerCommonAncestors and ConflictMarkerEnd are linked to the Error syntax group. To link them to another syntax group, use the following option:

" Default value
let g:conflict_marker_highlight_group = 'Error'

ConflictMarkerOurs, ConflictMarkerTheirs, and ConflictMarkerCommonAncestors are not linked to any syntax group by default, and can be used to customize the highlight of the ours and theirs parts of the conflict.

To use a specific highlight for each marker, disable the default highlight group, and define your own highlights for each syntax group.

Example:

" disable the default highlight group
let g:conflict_marker_highlight_group = ''

" Include text after begin and end markers
let g:conflict_marker_begin = '^<<<<<<<\+ .*$'
let g:conflict_marker_common_ancestors = '^|||||||\+ .*$'
let g:conflict_marker_end   = '^>>>>>>>\+ .*$'

highlight ConflictMarkerBegin guibg=#2f7366
highlight ConflictMarkerOurs guibg=#2e5049
highlight ConflictMarkerTheirs guibg=#344f69
highlight ConflictMarkerEnd guibg=#2f628e
highlight ConflictMarkerCommonAncestorsHunk guibg=#754a81

Screenshot_20190911_212653

Jump among Conflict Markers

[x and ]x mappings are defined as default. Use the following option to disable them:

let g:conflict_marker_enable_mappings = 0

Jump within a Conflict Marker

This feature uses matchit.vim, which is bundled in Vim (macros/matchit.vim). % mapping is extended by matchit.vim. Use the following option to disable this feature:

let g:conflict_marker_enable_matchit = 0

Resolve a Conflict with Various Strategies

This plugin defines mappings as default: ct for theirs, co for ours, cn for none and cb for both. Use the following option to disable mappings:

let g:conflict_marker_enable_mappings = 0

Theirs

<<<<<<< HEAD
ours
=======
theirs
>>>>>>> deadbeef0123

ct or :ConflictMarkerThemselves

theirs

Ours

<<<<<<< HEAD
ours
=======
theirs
>>>>>>> deadbeef0123

co or :ConflictMarkerOurselves

ours

Apply Both

<<<<<<< HEAD
ours
=======
theirs
>>>>>>> deadbeef0123

cb or :ConflictMarkerBoth

ours
theirs

Apply Both in Reverse Order

<<<<<<< HEAD
ours
=======
theirs
>>>>>>> deadbeef0123

cB or :ConflictMarkerBoth!

theirs
ours

Apply None

<<<<<<< HEAD
ours
=======
theirs
>>>>>>> deadbeef0123

cn or :ConflictMarkerNone

Customize

TODO

License

This plugin is distributed under MIT license.

Copyright (c) 2013 rhysd

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.