vim-conflicted


Ⅰ. 插件描述

Easy git merge conflict resolution in Vim

Ⅱ. 基本信息

创建日期:  2014-01-12
使用用户:  34
Github星:  182
插件作者:  Chris Toomey

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'christoomey/vim-conflicted'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'christoomey/vim-conflicted'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'christoomey/vim-conflicted'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/christoomey/vim-conflicted

Ⅳ. 文档说明

Conflicted

Conflicted is a Vim plugin that aids in resolving git merge and rebase

  1. It relies on [tpope's fugitive plugin][] to do the heavy lifting and
  2. 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

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

  1. These versions are:
  2. base - The common ancestor of the file in the upstream and local branches
  3. upstream - The core branch (usually master), that you are merging into
    or rebasing onto.
  4. local - The feature branch containing your changes
  5. 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

添加新评论