Shows colored signs in buffer indicating diff with original svn/git file,
Vim script
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
plugin
README

README

This is a mirror of http://www.vim.org/scripts/script.php?script_id=1881

Screenshot available at http://zevv.nl/play/code/vimscripts/

Introduction
------------

NOTE: This plugin is unix-only!

An small vim 7.0 plugin for showing RCS diff information in a file while
editing. This plugin runs a diff between the current buffer and the original
file from the version control system, and shows coloured signs indicating
where the buffer differs from the original file from the repository. The
original text is not shown, only signs are used to indicate where changes were
made. With proper key bindings configured, fast navigation between changed
blocks is also provided.

Despite the name 'svndiff' this plugin supports the following RCS systems:

- Subversion
- Git
- Mercurial
- Perforce / p4
- CVS
- Fossil

The type of RCS will be detected when first issuing a svndiff command on
the file.

The following symbols and syntax highlight groups are used for the signs:

  > DiffAdd:    Newly added lines. (default=blue)

  ! DiffChange: Lines which are changed from the original. (default=cyan)

  < DiffDel:    Applied to the lines directly above and below a deleted block
                (default=magenta)

Usage
-----

The plugin defines one function: Svndiff(). This function figures out the
difference between the current buffer and it's RCS original, and adds the
signs at the places where the buffer differs from the original file from svn
or git. You'll need to call this function after making changes to update the
highlighting.

The function takes one argument specifying an additional action to perform:

  "prev"  : jump to the previous different block
  "next"  : jump to the next different block
  "clear" : clean up all signs

You might want to map some keys to run the Svndiff function. For
example, add to your .vimrc:

  noremap <F3> :call Svndiff("prev")<CR>
  noremap <F4> :call Svndiff("next")<CR>
  noremap <F5> :call Svndiff("clear")<CR>


Configuration
-------------

The following configuration variables are availabe:

* g:svndiff_autoupdate

  If this variable is defined, svndiff will automatically update the signs
  when the user stops typing for a short while, and when leaving insert
  mode. This might slow things down on large files, so use with caution.
  The vim variable 'updatetime' can be used to set the auto-update interval,
  but note that changing this variable other effects as well. (refer to the
  vim docs for more info)
  To use, add to your .vimrc:

  let g:svndiff_autoupdate = 1

* g:svndiff_one_sign_delete

  Normally, two 'delete' signs are placed around the location where
  text was deleted. When this variable is defined, only one sign is
  placed, above the location of the deleted text.
  To use, add to your .vimrc:

  let g:svndiff_one_sign_delete = 1

Colors
------

Personally, I find the following colours more intuitive for diff colours:
red=deleted, green=added, yellow=changed. If you want to use these colours,
try adding the following lines to your .vimrc

hi DiffAdd      ctermfg=0 ctermbg=2 guibg='green'
hi DiffDelete   ctermfg=0 ctermbg=1 guibg='red'
hi DiffChange   ctermfg=0 ctermbg=3 guibg='yellow'

Changelog
---------

1.0 2007-04-02  Initial version

1.1 2007-04-02  Added goto prev/next diffblock commands

1.2 2007-06-14  Updated diff arguments from -u0 (obsolete) to -U0

2.0 2007-08-16  Changed from syntax highlighting to using signs, thanks
                to Noah Spurrier for the idea. NOTE: the name of the
                function changed from Svndiff_show() to Svndiff(), so
                you might need to update your .vimrc mappings!

3.0 2008-02-02  Redesign with some ideas from Jan Bezdekovsky. The
                diff is only updated when the buffer actually changes,
                cleanup of signs is now done properly and some info
                about each diff block is printed in the status line.

3.1 2008-02-04  Fixed bug that broke plugin in non-english locales, thanks
                to Bernhard Walle for the patch

3.2 2008-02-27  The latest rewrite broke vim 6 compatiblity. The plugin
                is now simply disabled for older vim versions to avoid
                a lot of warnings when loading.

4.0 2008-11-24  Added GIT support. The RCS type is now detected (svn/git)

4.1 2008-11-25  Added CVS support.

4.2 2009-07-31  Added support for proper handling of non-unix file formats
                which use different newline conventions (dos, mac)

4.3 2010-05-08  Added support for Mercurial, fixed git support (thanks
                Frankovskyi Bogdan)

4.4 2011-03-30  Added support for perforce/p4 (thanks, Timandahaf)

4.5 2011-10-09  Bugfix when trying to use svndiff in a new fileless buffer (Frankovskyi Bogdan)

4.6 2012-06-02  Added support for the Fossil SCM (Andrea Federico Grisotto)