This plugin finds and highlights word or character based changed/added/deleted diff units in a diff format, to make it possible to see the actual differences within a line. This plugin not only works as an additional vim syntax for diff format but also applies the inline diff unit highlighting on some popular git-related plugins.
When a file name extension is .diff or the syntax option is set to diff,
a diff file in unified format will be shown like this:
This plugin does:
- identify either of unified, context, or normal "ed" style diff format, which
can be provided by some program like
diffandgit diffcommands - find a pair of corresponding changed lines to be compared in a buffer
- realign them to most similar lines if
linematchis set in thediffoptoption - split each line to a list of diff units, based on the
DiffUnitbuffer-local or global variable - compare them and find the changed/added/deleted units, using a builtin
diff()function or a plugin specific function along with thediffoptoption - highlight those diff units according to syntax, text property, or extended
mark mechanism applied on the buffer, using single or several
background-colored highlight groups, based on the
DiffColorsbuffer-local or global variable
In addition to those standard diff formats, this plugin identifies a file
including git conflict markers and diff indicators (-/+ and </>),
and then shows the diff units.
In some popular git-related plugins, to show git diff output and to preview
a diff hunk in normal, preview, and popup/floating windows, another
highlighting mechanism such as text property or extended mark is used instead
of diff syntax. This plugin applies the inline diff unit highlighting and show
actual differences on them, based on the DiffUnitSyntax buffer-local or
global variable, on the following plugins (you are welcome to introduce more
plugins to support!):
In normal window (when DiffUnitSyntax is set to 1):
vim-fugitive >
neogit >
mini.git >
vim-gin >
In preview and popup/floating windows (when DiffUnitSyntax is set to 2):
gtsigns.nvim >
vim-gitgutter >
vim-signify >
-
b:DiffUnit,g:DiffUnit: A type of diff unitValue Description 'Char' any single character 'Word1' \w\+word and any\Wsingle character (default)'Word2' non-space and space words 'Word3' \<or\>character class boundaries (set byiskeywordoption)'word' see word'WORD' see WORD -
b:DiffColors,g:DiffColors: Highlight group for changed units (hl-DiffAddfor added units)Value Description 0 hl-DiffChange1 hl-DiffChange+ several highlight groups (default) -
b:DiffUnitSyntax,g:DiffUnitSyntax: Disable this plugin or apply diff unit highlightingValue Description 0 disable 1 enable in normal window (default) 2 enable in normal, preview, and popup/floating windows









