Home Explore Blog CI



neovim

7th chunk of `runtime/doc/diff.txt`
5eb36d1c1f722ffbfb920a979616e6449c74a7e64abe03ee0000000100000c32

binaries isn't useful.  The "--binary" argument makes the files read in binary
mode, so that a CTRL-Z doesn't end the text on DOS.

The `redraw!` command may not be needed, depending on whether executing a
shell command shows something on the display or not.

If the 'diffexpr' expression starts with s: or |<SID>|, then it is replaced
with the script ID (|local-function|). Example: >
		set diffexpr=s:MyDiffExpr()
		set diffexpr=<SID>SomeDiffExpr()
Otherwise, the expression is evaluated in the context of the script where the
option was set, thus script-local items are available.

						*E810* *E97*
Vim will do a test if the diff output looks alright.  If it doesn't, you will
get an error message.  Possible causes:
-  The "diff" program cannot be executed.
-  The "diff" program doesn't produce normal "ed" style diffs (see above).
-  The 'shell' and associated options are not set correctly.  Try if filtering
   works with a command like ":!sort".
-  You are using 'diffexpr' and it doesn't work.
If it's not clear what the problem is set the 'verbose' option to one or more
to see more messages.

The self-installing Vim for MS-Windows includes a diff program.  If you don't
have it you might want to download a diff.exe.  For example from
https://gnuwin32.sourceforge.net/packages/diffutils.htm.


USING PATCHES					*diff-patchexpr*

The 'patchexpr' option can be set to use something else than the standard
"patch" program.

When 'patchexpr' is empty, Vim will call the "patch" program like this: >

	patch -o outfile origfile < patchfile

This should work fine with most versions of the "patch" program.  Note that a
CR in the middle of a line may cause problems, it is seen as a line break.

If the default doesn't work for you, set the 'patchexpr' to an expression that
will have the same effect.  These variables are set to the file names used:

	v:fname_in		original file
	v:fname_diff		patch file
	v:fname_out		resulting patched file

The advantage of using a function call without arguments is that it is faster,
see |expr-option-function|.

Example (this does the same as 'patchexpr' being empty): >

	set patchexpr=MyPatch()
	function MyPatch()
	   :call system("patch -o " .. v:fname_out .. " " .. v:fname_in ..
	   \  " < " .. v:fname_diff)
	endfunction

Make sure that using the "patch" program doesn't have unwanted side effects.
For example, watch out for additionally generated files, which should be
deleted.  It should just patch the file and nothing else.
   Vim will change directory to "/tmp" or another temp directory before
evaluating 'patchexpr'.  This hopefully avoids that files in the current
directory are accidentally patched.  Vim will also delete files starting with
v:fname_in and ending in ".rej" and ".orig".

If the 'patchexpr' expression starts with s: or |<SID>|, then it is replaced
with the script ID (|local-function|). Example: >
		set patchexpr=s:MyPatchExpr()
		set patchexpr=<SID>SomePatchExpr()
Otherwise, the expression is evaluated in the context of the script where the
option was set, thus script-local items are available.


 vim:tw=78:ts=8:noet:ft=help:norl:

Title: Troubleshooting Diff Expressions and Using Patches
Summary
This section covers troubleshooting 'diffexpr', including common causes for errors such as problems with the diff program, incorrect shell settings, or issues with the custom expression. It also discusses using 'patchexpr' to specify an alternative patch program. It details the default 'patch' command used by Vim, how to customize it using 'patchexpr', and the variables available for file names. It stresses the importance of ensuring the patch program only modifies the specified file and explains the directory change to '/tmp' before evaluating 'patchexpr' to avoid accidental patching.