Coder Social home page Coder Social logo

bryant1410 / vim-diff-enhanced Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chrisbra/vim-diff-enhanced

0.0 1.0 0.0 284 KB

Better Diff options for Vim

Home Page: http://www.vim.org/scripts/script.php?script_id=5121

Makefile 17.46% Vim Script 74.97% Shell 7.57%

vim-diff-enhanced's Introduction

EnhancedDiff plugin

A Vim plugin for creating better diffs (sometimes)

This plugin allows you to make use of the Patience diff algorithm for generating diffs to use with Vim. This needs the git command line tool available.

You can also customize your setup to use any other tool to generated diffs (e.g. mercurial) Read the help on how to configure the plugin accordingly.

Here are some screenshots that visualize how the patience/histogram algorithm work.

This is the default diff generated by Vim: Default diff

Now change that to using the "histogram" algorithm by running :EnhancedDiff histogram If Vim is in diff mode, the diff will be updated to this:

histogram diff

Note, that the Patience algorithm might not always provide better diffs. But using this plugin you can at least easily switch between different diffs.

Ignoring parts of a afile

Using the command :EnhancedDiffIgnorePat pat you can define patterns, that will be ignored before feeding the buffer contents to the diff program. Internally this will be handled by substituting those matches with 'XX' so that the content will look like the same for the diff binary.

This is how it looks like with a pattern of ^[^;]\+; and ;[^;]\+$ diff_ignore

Installation

Use the plugin manager of your choice:

  • Pathogen
    • git clone https://github.com/chrisbra/vim-diff-enhanced.git ~/.vim/bundle/vim-enhanced-diff
    • :Helptags (only needed once after the installation to install the documentation)
  • NeoBundle
    • NeoBundle 'chrisbra/vim-diff-enhanced'
  • Vundle
    • Plugin 'chrisbra/vim-diff-enhanced'
  • Vim-Plug
    • Plug 'chrisbra/vim-diff-enhanced'

Alternatively download the stable version of the plugin, edit it with Vim (vim EnhancedDiff-XXX.vmb) and simply source it (:so %). Restart and take a look at the help (:h EnhancedDiff.txt)

Usage

Once installed, take a look at the help at :h EnhancedDiff

Here is a short overview of the functionality provided by the plugin:

Ex commands:

:PatienceDiff - Use the Patience Diff algorithm for the next diff mode

:EnhancedDiff <algorithm> - Use <algorithm> to generate the diff. Use any of

  • myers Default Diff algorithm used
  • default Alias for myers algorithm
  • histogram Fast version of patience algorithm
  • minimal Default diff algorithm, trying harder to minimize the diff
  • patience Patience diff algorithm.

Note: Those 2 commands use the git command line tool internally to generate the diffs. Make sure you have at least git version 1.8.2 installed.

:EnhancedDiffDisable - Disable plugin (and use default Vim diff capabilities).

FAQ

How can I enable the patience diff algorithm when starting as vimdiff / git difftool / ... ?

In that case, add this snippet to your .vimrc:

" started In Diff-Mode set diffexpr (plugin not loaded yet)
if &diff
    let &diffexpr='EnhancedDiff#Diff("git diff", "--diff-algorithm=patience")'
endif

License & Copyright

© 2015 by Christian Brabandt. The Vim License applies. See :h license

NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK

vim-diff-enhanced's People

Contributors

bryant1410 avatar chrisbra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.