sponsor Vim development Vim logo Vim Book Ad

svndiff : Shows colored signs in buffer indicating diff with original svn/git file,

 script karma  Rating 122/41, Downloaded by 3451    Comments, bugs, improvements  Vim wiki

created by
Ico -
 
script type
utility
 
description
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)

 
install details
Copy the file into your ~/.vim/plugin directory, and optionally create a keymap as described above.
 

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
svndiff.vim 4.7 2013-04-25 7.0 Ico - Fixed git diffs when cwd is not the top git directory.
svndiff.vim 4.6 2012-06-02 7.0 Ico - Added support for Fossil
svndiff.vim 4.6 2012-06-02 7.0 Ico - Added support for the Fossil SCM
svndiff.vim 4.5 2011-10-09 7.0 Ico - Bugfix when trying to use svndiff on a new buffer without file
svndiff.vim 4.4 2011-03-30 7.0 Ico - Added support for perforce/p4.

Supported RCS software is now subversion, git, mercurial, cvs and perforce!
svndiff.vim 4.3 2010-05-08 6.0 Ico - Added support for Mercurial, fixed Git support
svndiff.vim 4.1 2008-11-25 6.0 Ico - Added CVS support. svndiff now works with subversion, GIT and CVS.
svndiff.vim 4.0 2008-11-24 6.0 Ico - Added support for GIT, repository type is detected at runtime (subversion / git)
svndiff.vim 3.2 2008-02-27 7.0 Ico - 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.
svndiff.vim 3.1 2008-02-04 6.0 Ico - Fixed script behaviour for non-english locales.
svndiff.vim 3.0 2008-02-03 6.0 Ico - Major redesign of the plugin:

* auto-update feature highlights svn diff signs while editing
* signs from other sources (debugger, etc) are no longer effected
* better performance, diff is only executed when code is actually modified
svndiff.vim 2.0 2007-08-16 7.0 Ico - svndiff now uses tags to indicated the difference between the buffer and the original file, so it leaves intact the original syntax highlighting.
svndiff.vim 1.2 2007-06-14 6.0 Ico - updated to work with recent version of diff (-u0 option was obsolete, changed to -U0)
svndiff.vim 1.1 2007-05-02 7.0 Ico - Added jump-to-prev/next
ip used for rating: 54.197.87.25

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