• Stars
    star
    271
  • Rank 151,717 (Top 3 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy git merge conflict resolution in Vim

Conflicted

Conflicted is a Vim plugin that aids in resolving git merge and rebase conflicts. It relies on tpope's fugitive plugin to do the heavy lifting and provides a few wrapper commands and a streamlined workflow to make resolving conflicts much more straightforward.

Usage

From git

The easist way to use Conflicted from git is to add an alias for it that opens vim with the conflicted plugin activated. You can add the alias with the following shell command:

git config --global alias.conflicted '!vim +Conflicted'

From there, you can run conflicted directly from git with:

git conflicted

Which will open Vim and start up the plugin.

Or if you prefer to start Conflicted via git mergetool:

# Define a custom mergetool called `vim-conflicted` that runs `vim +Conflicted`
git config --global mergetool.vim-conflicted.cmd 'vim +Conflicted'
# Set the `vim-conflicted` mergetool to be used when `git mergetool` is executed
git config --global merge.tool 'vim-conflicted'

Commands

Conflicted provides three primary commands for working with conflicts:

Conflicted

Conflicted will add all the conflicted files to Vim's arglist and open the first in Merger mode.

GitNextConflict

After editing the merged file to resolve the conflict and remove all conflict markers, running GitNextConflict will mark the file as resolved and open the next file in Merger mode for resolution.

If you are on the last file, GitNextConflict will quit Vim.

Merger

Merger will open the various views of the conflicted file. This command is exposed for completeness, but likely you will not need to call this command directly as both Conflicted and GitNextConflict will call it for you.

Diffget Mappings

Conflicted provides mappings to perform a diffget from the working version of the file, pulling from either the upstream or local version. These mappings are provided in both normal and visual mode:

  1. dgu - diffget from the upstream version
  2. dgl - diffget from the local version

If you would prefer different mappings, you can overide with the following in your vimrc:

" Use `gl` and `gu` rather than the default conflicted diffget mappings
let g:diffget_local_map = 'gl'
let g:diffget_upstream_map = 'gu'

Tabline

Conflicted will configure the tab label to display the name of the revision in the tab. This is done via the tabline setting in terminal Vim, and the guitablabel setting in graphical Vim, ie MacVim.

Terminal tabline

MacVim tab Label

Statusline Integration

Add the following to your vimrc to display the version name of each split in the vim statusbar:

set stl+=%{ConflictedVersion()}

Normally it will not add anything to the statusline, but if you are in conflicted mode then it will add the conflicted version, ie 'local', 'working', etc.

Statusline

Custom settings for Conflicted buffers

When Conflicted has finished setting up, it will call the user autocmd VimConflicted.

Usage example:

 function! s:setupConflicted()
     set stl+=%{ConflictedVersion()}
     " Resolve and move to next conflicted file.
     nnoremap ]m :GitNextConflict<cr>
 endfunction
 autocmd myVimrc User VimConflicted call s:setupConflicted()

Installation

If you don't have a preferred installation method, I recommend using Vundle. Assuming you have Vundle installed and configured, the following steps will install the plugin:

Add the following line to your ~/.vimrc and then run BundleInstall from within Vim:

" Fugitive is required for Conflicted
Bundle 'tpope/vim-fugitive'
Bundle 'christoomey/vim-conflicted'

Overview

Versions

Conflicted makes reference to four different versions of each conflicted file. These versions are:

  1. base - The common ancestor of the file in the upstream and local branches
  2. upstream - The core branch (usually master), that you are merging into or rebasing onto.
  3. local - The feature branch containing your changes
  4. working - The final combined version of the file

Tabs

For each conflicted file, Conflicted will open 3 tabs, each with a different diff view presented:

  1. Gdiffsplit! 3-way - 3 way diff comparing the upstream, working, and local versions of the file.

Tab 1 - Working

  1. Upstream Changes - A 2 way diff between the base and upstream versions of the file.

Tab 2 - Upstream

  1. Local Changes - A 2 way diff between the base and local versions of the file.

Tab 3 - Local

More Repositories

1

vim-tmux-navigator

Seamless navigation between tmux panes and vim splits
Vim Script
5,206
star
2

dotfiles

My vim, zsh, git, tmux, and other config files and utility scripts.
Shell
466
star
3

vim-system-copy

Vim plugin for copying to the system clipboard with text-objects and motions
Vim Script
345
star
4

vim-tmux-runner

Vim and tmux, sittin' in a tree...
Vim Script
291
star
5

vim-sort-motion

Vim mapping for sorting a range of text
Vim Script
250
star
6

your-first-vim-plugin

Samples and notes for my Aug 2014 'Your First Vim Plugin' talk
Vim Script
129
star
7

vim-titlecase

Teach Vim about titlecase, with support for motions and text objects
Vim Script
103
star
8

vim-quicklink

A Vim plugin for quickly looking up a topic in google and inserting the relevant link
Vim Script
55
star
9

boston-react-conf-2018-graphql-talk

Sample repo for my Boston React Conf 2018 talk on React & GraphQL
JavaScript
31
star
10

vim-run-interactive

Vim plugin to run shell commands in an interactive shell
Vim Script
26
star
11

vim-rfactory

Vim plugin for rapid navigation to FactoryBot factory definition
Ruby
23
star
12

display-table-summary

Vim Script
8
star
13

vim-presentation-mode

Vim Script
8
star
14

vim-textobj-codeblock

Vim Script
7
star
15

alfred-trello-boards

Alfred workflow for quick navigation to Trello boards
Ruby
7
star
16

vim-kata-meetup

Support repo for 2012-11-12 Boston Vim meetup
Ruby
5
star
17

ctrlp-generic

A generic list selection extension to CtrlP for vim
Vim Script
4
star
18

magictags

Automatic generation of tags file from Vim
Vim Script
4
star
19

vim-g-dot

Vim command to repeat last change over a number of lines
Vim Script
4
star
20

typescript-intro-presentation

3
star
21

live-down

Markdown rendering and live-reloading
3
star
22

conway

jQuery & coffeescript implementation of Conway's Game of Life
CoffeeScript
3
star
23

vim-colors-ctoomey

My colorschemes for vim
Vim Script
3
star
24

react-native-graphql

JavaScript
2
star
25

emit

Fun with canvas animation
Ruby
2
star
26

zero

A web app to monitor your inbox zero status over time
Ruby
2
star
27

elm-reaction

Elm
1
star
28

gsub.vim

Vim Script
1
star
29

inertia-svelte-repro

Ruby
1
star
30

vim-swiki

Vim plugin for simple wiki management
Vim Script
1
star
31

trusted-local

Vim Script
1
star