Vim Recall繁體中文

Apply a patch and show differences

:diffpatch

Example

Normal 0 / 2
old
Cursor on line 1, column 1

Apply a patch and show differences.

Windows

old.txt Active
old
Before & after
Before
old
Cursor on line 1, column 1

Windows

old.txt Active
old
After
new
Cursor on line 1, column 1

Windows

old.txt
old
Patched result Active
new

Diff regions

Line 1
old ↔ new

Documentation-backed illustration. +diff, unrestricted mode, splitbelow, diffopt without vertical, a working patch program or equivalent patchexpr, and this exact single-file patch. :diffpatch applies the single-file patch to a copy and opens the new result in a diff split; old.txt stays intact. Primary help: :diffpatch.

Details & Vim help

Apply a patch and show differences. This Ex reference uses the full command name; the alphabetical index omits arguments. Supply the ranges, arguments, flags and prerequisite state documented in the linked help. Press Enter to submit a complete command. The index spelling :diffp[atch] puts the optional abbreviation suffix in square brackets; those brackets are not typed. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative.