sponsor Vim development Vim logo Vim Book Ad

ConflictMotions : Motions to and inside SCM conflict markers.

 script karma  Rating 14/5, Downloaded by 277    Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
script type
This plugin defines movement commands and text objects to go to and operate on
conflicting lines, as indicated by many revision control systems, like
Subversion, Git, etc. The source code management system inserts conflict
markers such as <<<<<<<, =======, and >>>>>>> on merges to indicate that the
automatic resolution failed; this plugin helps you with locating and resolving
these conflicts.

To be alerted to the existence of conflict markers and to visually
differentiate the conflicted lines, you can use the highlighting, warnings and
custom buffer status provided by the companion ConflictDetection.vim plugin
(vimscript #4129).

]x                      Go to [count] next start of a conflict.
]X                      Go to [count] next end of a conflict.
[x                      Go to [count] previous start of a conflict.
[X                      Go to [count] previous end of a conflict.

]=                      Go to [count] next conflict marker.
[=                      Go to [count] previous conflict marker.
                        Mnemonic: = is in the separator between our and their

ax                      "a conflict" text object, select [count] conflicts,
                        including the conflict markers.

a=                      "a conflict section" text object, select [count]
                        sections (i.e. either ours, theirs, or base) including
                        the conflict marker above, and in the case of "theirs"
                        changes, also the ending conflict marker below.

i=                      "inner conflict section" text object, select current
                        section (i.e. either ours, theirs, or base) without
                        the surrounding conflict markers.

:ConflictTake           From the conflict the cursor is in, remove the markers
                        and keep the section the cursor is inside.
:ConflictTake [none this ours base theirs both all query] [...]
:ConflictTake [-.<|>+*?][...]
                        From the conflict the cursor is in, remove the markers
                        and keep the passed section(s) (in the order they are
                            none, - = delete the entire conflict
                            both    = ours theirs               (+ = <>)
                            all     = ours [base] theirs        (* = <|>)
                            query   = ask which sections to take
:[range]ConflictTake [none this ours base theirs both all range query] [...]
:[range]ConflictTake [-.<|>+*:?][...]
                        When the cursor is inside a conflict, and the [range]
                        covers part of that conflict:
                        From the conflict the cursor is in, remove the markers
                        and keep the passed range (without contained markers)
                        (and any passed sections in addition; include the
                        "range" argument to put the range somewhere other than
                        the end).
                        Otherwise, when a large range (like %) is passed:
                        For each conflict that starts in [range], remove the
                        markers and keep the passed section(s) / ask which
                        section(s) should be kept. You can answer the question
                        with either the symbol or the choice's starting
                        letter. An uppercase letter will apply the choice to
                        all following conflicts.

<Leader>xd              Delete the entire current conflict.
<Leader>x.              Keep the current conflict section, delete the rest.
<Leader>x<              Keep our changes, delete the rest.
<Leader>x|              Keep the change base, delete the rest.
<Leader>x>              Keep their changes, delete the rest.
install details
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 ConflictMotions*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

- Requires Vim 7.0 or higher.
- Requires the CountJump plugin (vimscript #3130).
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.004 or

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

To change the default motion mappings, use:
    let g:ConflictMotions_ConflictBeginMapping = 'x'
    let g:ConflictMotions_ConflictEndMapping = 'X'
    let g:ConflictMotions_MarkerMapping = '='
To also change the [ / ] prefix to something else, follow the instructions for
CountJump-remap-motions. (This requires CountJump 1.60.)

To change the default text object mappings, use:
    let g:ConflictMotions_ConflictMapping = 'x'
    let g:ConflictMotions_SectionMapping = '='
To also change the i / a prefix to something else, follow the instructions for
CountJump-remap-text-objects. (This requires CountJump 1.60.)

If you don't want the mappings for :ConflictTake:
    let g:ConflictMotions_TakeMappingPrefix = ''
To redefine the mappings, either clear the prefix and use the
<Plug>(ConflictMotionsTake...) mapping targets, or adapt via the prefix and
mapping configuration, e.g.:
    let g:ConflictMotions_TakeMappingPrefix = '<Leader>='
    let g:ConflictMotions_TakeMappings = [['d', 'None'], ['x', 'This'], ['o', 'Ours'], ['b', 'Base'], ['t', 'Theirs']]

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
ConflictMotions-2.00.vmb.gz 2.00 2013-04-23 7.0 Ingo Karkat - FIX: Don't create the default mapping for <Plug>(ConflictMotionsTakeSelection) in select mode; it should insert a literal <Leader> there.
- Add the :ConflictTake command to resolve a conflict by picking a section(s).
- Add dependency to ingo-library (vimscript #4433).
ConflictMotions-1.10.vmb.gz 1.10 2012-09-06 7.0 Ingo Karkat The [z / ]z mappings disable the built-in mappings for moving over the current open fold. Oops! Change default to [= / ]= / i= / a=. (= as for the characters in the separator between our and their change).
ConflictMotions.vba.gz 1.00 2012-03-28 7.0 Ingo Karkat Initial upload
ip used for rating:

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.
SourceForge.net Logo