Skip to content

rickhowe/diffunitsyntax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diffunitsyntax

Highlight word or character based diff units in diff format

This plugin is an additional vim syntax for diff format and highlights changed and added diff units on word or character basis.

For example, a diff file in unified format will be shown like this:

unified

This syntax plugin does:

  • identify either of unified, context, or normal "ed" style diff format, which can be provided by some program like diff and git diff commands
  • find corresponding changed lines to be compared
  • split each line to a list of diff units, based on the DiffUnit buffer-local or global variable
  • compare them and find the changed and added units, using a builtin diff() function or a plugin specific function along with the diffopt option
  • show those units in single or several background-colored syntax highlights, based on the DiffColors buffer-local or global variable

In addition to those diff formats, if the file extension is ".diff" or the syntax option is set to "diff", this syntax plugin identifies a file including git conflict markers and shows the diff units like this:

gitconflict

Options

  • b:DiffUnit, g:DiffUnit: A type of diff unit

    Value Description
    'Char' any single character
    'Word1' \w\+ word and any \W single character (default)
    'Word2' non-space and space words
    'Word3' \< or \> character class boundaries (set by iskeyword option)
    'word' see word
    'WORD' see WORD
  • b:DiffColors, g:DiffColors: Highlight group for changed units (hl-DiffAdd for added units)

    Value Description
    0 hl-DiffChange
    1 hl-DiffChange + several highlight groups (default)
  • b:DiffUnitSyntax, g:DiffUnitSyntax : Enable or disable this syntax plugin

    Value Description
    0 disable
    1 enable (default)

About

Highlight word or character based diff units in diff format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published