been made to the text
- "filler" is not present in 'diffopt', deleted/inserted lines makes the
alignment go wrong
All the buffers edited in a window where the 'diff' option is set will join in
the diff. This is also possible for hidden buffers. They must have been
edited in a window first for this to be possible. To get rid of the hidden
buffers use `:diffoff!`.
*:DiffOrig* *diff-original-file*
Since 'diff' is a window-local option, it's possible to view the same buffer
in diff mode in one window and "normal" in another window. It is also
possible to view the changes you have made to a buffer since the file was
loaded. Since Vim doesn't allow having two buffers for the same file, you
need another buffer. This command is useful: >
command DiffOrig vert new | set buftype=nofile | read ++edit # | 0d_
\ | diffthis | wincmd p | diffthis
Use ":DiffOrig" to see the differences
between the current buffer and the file it was loaded from.
A buffer that is unloaded cannot be used for the diff. But it does work for
hidden buffers. You can use ":hide" to close a window without unloading the
buffer. If you don't want a buffer to remain used for the diff do ":set
nodiff" before hiding it.
*:dif* *:diff* *:diffupdate*
:dif[fupdate][!] Update the diff highlighting and folds.
Vim attempts to keep the differences updated when you make changes to the
text. This mostly takes care of inserted and deleted lines. Changes within a
line and more complicated changes do not cause the differences to be updated.
To force the differences to be updated use: >
:diffupdate
If the ! is included Vim will check if the file was changed externally and
needs to be reloaded. It will prompt for each changed file, like `:checktime`
was used.
Vim will show filler lines for lines that are missing in one window but are
present in another. These lines were inserted in another file or deleted in
this file. Removing "filler" from the 'diffopt' option will make Vim not
display these filler lines.
Folds are used to hide the text that wasn't changed. See |folding| for all
the commands that can be used with folds.
The context of lines above a difference that are not included in the fold can
be set with the 'diffopt' option. For example, to set the context to three
lines: >
:set diffopt=filler,context:3
The diffs are highlighted with these groups:
|hl-DiffAdd| DiffAdd Added (inserted) lines. These lines exist in
this buffer but not in another.
|hl-DiffChange| DiffChange Changed lines.
|hl-DiffText| DiffText Changed text inside a Changed line. Exact
behavior depends on the `inline:` setting in
'diffopt'.
With `inline:` set to "simple", Vim finds the
first character that is different, and the
last character that is different (searching
from the end of the line). The text in
between is highlighted. This means that parts
in the middle that are still the same are
highlighted anyway. The 'diffopt' flags
"iwhite" and "icase" are used here.
With `inline:` set to "char" or "word", Vim
uses the internal diff library to perform a
detailed diff between the changed blocks and
highlight the exact difference between the
two. Will respect any 'diffopt' flag that
affects internal diff.
Not used when `inline:` is set to "none".
|hl-DiffTextAdd| DiffTextAdd Added text inside a Changed line. Similar to
DiffText, but used when there is no
corresponding text in other buffers. Not used
when `inline:` is set to "simple" or "none".
|hl-DiffDelete| DiffDelete Deleted lines. Also called filler lines,
because they don't really exist in this
buffer.
==============================================================================
3. Jumping to diffs *jumpto-diffs*
Two commands can be used to jump to diffs:
*[c*
[c Jump backwards to the previous start of a change.
When a count is used, do it that many times.
*]c*
]c Jump forwards to