xref: /freebsd/usr.bin/sdiff/sdiff.1 (revision 5b56413d04e608379c9a306373554a8e4d321bc0)
1.\" $OpenBSD: sdiff.1,v 1.15 2007/06/29 14:48:07 jmc Exp $
2.\"
3.\" Written by Raymond Lai <ray@cyth.net>.
4.\" Public domain.
5.\"
6.Dd February 16, 2024
7.Dt SDIFF 1
8.Os
9.Sh NAME
10.Nm sdiff
11.Nd side-by-side diff
12.Sh SYNOPSIS
13.Nm
14.Op Fl abdilstHW
15.Op Fl I Ar regexp
16.Op Fl o Ar outfile
17.Op Fl w Ar width
18.Ar file1
19.Ar file2
20.Sh DESCRIPTION
21.Nm
22displays two files side by side,
23with any differences between the two highlighted as follows:
24new lines are marked with
25.Sq \*(Gt ;
26deleted lines are marked with
27.Sq \*(Lt ;
28and changed lines are marked with
29.Sq \*(Ba .
30.Pp
31.Nm
32can also be used to interactively merge two files,
33prompting at each set of differences.
34See the
35.Fl o
36option for an explanation.
37.Pp
38The options are:
39.Bl -tag -width Ds
40.It Fl l -left-column
41Only print the left column for identical lines.
42.It Fl o -output Ar outfile
43Interactively merge
44.Ar file1
45and
46.Ar file2
47into
48.Ar outfile .
49In this mode, the user is prompted for each set of differences.
50See
51.Ev EDITOR
52and
53.Ev VISUAL ,
54below,
55for details of which editor, if any, is invoked.
56.Pp
57The commands are as follows:
58.Bl -tag -width Ds
59.It Cm l | 1
60Choose left set of diffs.
61.It Cm r | 2
62Choose right set of diffs.
63.It Cm s
64Silent mode \(en identical lines are not printed.
65.It Cm v
66Verbose mode \(en identical lines are printed.
67.It Cm e
68Start editing an empty file, which will be merged into
69.Ar outfile
70upon exiting the editor.
71.It Cm e Cm l
72Start editing file with left set of diffs.
73.It Cm e Cm r
74Start editing file with right set of diffs.
75.It Cm e Cm b
76Start editing file with both sets of diffs.
77.It Cm q
78Quit
79.Nm .
80.El
81.It Fl s -suppress-common-lines
82Skip identical lines.
83.It Fl w -width Ar width
84Print a maximum of
85.Ar width
86characters on each line.
87The default is 130 characters.
88.El
89.Pp
90Options passed to
91.Xr diff 1
92are:
93.Bl -tag -width Ds
94.It Fl a -text
95Treat
96.Ar file1
97and
98.Ar file2
99as text files.
100.It Fl b -ignore-space-change
101Ignore trailing blank spaces.
102.It Fl d -minimal
103Minimize diff size.
104.It Fl I -ignore-matching-lines Ar regexp
105Ignore line changes matching
106.Ar regexp .
107All lines in the change must match
108.Ar regexp
109for the change to be ignored.
110.It Fl i -ignore-case
111Do a case-insensitive comparison.
112.It Fl t -expand-tabs
113Expand tabs to spaces.
114.It Fl W -ignore-all-space
115Ignore all spaces.
116.It Fl B -ignore-blank-lines
117Ignore blank lines.
118.It Fl E -ignore-tab-expansion
119Treat tabs and eight spaces as the same.
120.It Fl H -speed-large-files
121Assume scattered small changes in a large file.
122.It Fl -ignore-file-name-case
123Ignore the case of file names.
124.It Fl -no-ignore-file-name-case
125Do not ignore file name case.
126.It Fl -strip-trailing-cr
127Skip identical lines.
128.It Fl -tabsize Ar NUM
129Change the size of tabs (default is 8.)
130.El
131.Sh ENVIRONMENT
132.Bl -tag -width Ds
133.It Ev EDITOR , VISUAL
134Specifies an editor to use with the
135.Fl o
136option.
137If both
138.Ev EDITOR
139and
140.Ev VISUAL
141are set,
142.Ev VISUAL
143takes precedence.
144If neither
145.Ev EDITOR
146nor
147.Ev VISUAL
148are set,
149the default is
150.Xr vi 1 .
151.It Ev TMPDIR
152Specifies a directory for temporary files to be created.
153The default is
154.Pa /tmp .
155.El
156.Sh SEE ALSO
157.Xr cmp 1 ,
158.Xr diff 1 ,
159.Xr diff3 1 ,
160.Xr vi 1 ,
161.Xr re_format 7
162.Sh AUTHORS
163.Nm
164was written from scratch for the public domain by
165.An Ray Lai Aq ray@cyth.net .
166.Sh CAVEATS
167Tabs are treated as anywhere from one to eight characters wide,
168depending on the current column.
169Terminals that treat tabs as eight characters wide will look best.
170