BSD 2 development
[unix-history] / man / ex.u
CommitLineData
eeb91390
BJ
1.TH EX UCB 4/4/79 UCB
2.SH NAME
3ex \- text editor
4.SH SYNOPSIS
5.B ex
6[
7.B \-
8] [
9.B \-v
10] [
11.B \-t
12tag
13] [
14.B \-r
15] [
16\fB\+\fIlineno\fR
17]
18name ...
19.SH DESCRIPTION
20.I Ex
21is the root of a family of editors:
22.I edit,
23.I ex
24and
25.I vi.
26.I Ex
27is a superset of
28.I ed,
29with the most notable extension being a display editing facility.
30Display based editing is the focus of
31.I vi.
32.PP
33If you have not used
34.I ed,
35or are a casual user, you will find that the editor
36.I edit
37is convenient for you.
38It avoids some of the complexities of
39.I ex
40used mostly by systems programmers and persons very familiar with
41.I ed.
42.PP
43If you have a \s-2CRT\s0 terminal, you may wish to use a display
44based editor; in this case
45see
46.IR vi (UCB),
47which is a command which focuses on the display editing portion of
48.I ex.
49.SH DOCUMENTATION
50For
51.I edit
52and
53.I ex
54see the
55.I "Ex/edit command summary \- Version 2.0."
56The document
57.I "Edit: A tutorial"
58provides a comprehensive introduction to
59.I edit
60assuming no previous knowledge of computers or the \s-2UNIX\s0 system.
61.PP
62The
63.I "Ex Reference Manual \- Version 2.0"
64is a comprehensive and complete manual for the command mode features
65of
66.I ex,
67but you cannot learn to use the editor by reading it.
68For an introduction to
69more advanced forms of editing using the command mode of
70.I ex
71see the editing documents written by Brian Kernighan for the editor
72.I ed;
73the material in the introductory and advanced documents works also with
74.I ex.
75.PP
76.I "An Introduction to Display Editing with Vi"
77introduces the display editor
78.I vi
79and provides reference material on
80.I vi.
81The
82.I "Vi Quick Reference"
83card summarizes the commands
84of
85.I vi
86in a useful, functional way, and is useful with the
87.I Introduction.
88.SH FOR ED USERS
89If you have used
90.I ed
91you will find that
92.I ex
93has a number of new features useful on CRT terminals.
94Intelligent terminals and high speed terminals are very pleasant to use
95with
96.I vi.
97Generally, the editor uses far more of the capabilities of terminals than
98.I ed
99does, and uses the terminal capability data base
100.IR termcap (UCB)
101and the type of the terminal you are using from the variable
102TERM in the environment to determine how to drive your terminal efficiently.
103The editor makes use of features such as insert and delete character and line
104in its
105.B visual
106command
107(which can be abbreviated \fBvi\fR)
108and which is the central mode of editing when using
109.IR vi (UCB).
110There is also an interline editing
111.B open
112(\fBo\fR)
113command which works on all terminals.
114.PP
115.I Ex
116contains a number of new features for easily viewing the text of the file.
117The
118.B z
119command gives easy access to windows of text.
120Hitting ^D causes the editor to scroll a half-window of text
121and is more useful for quickly stepping through a file than just hitting
122return.
123Of course, the screen oriented
124.B visual
125mode gives constant access to editing context.
126.PP
127.I Ex
128gives you more help when you make mistakes.
129The
130.B undo
131(\fBu\fR)
132command allows you to reverse any single change which goes astray.
133.I Ex
134gives you a lot of feedback, normally printing changed lines,
135and indicates when more than a few lines are affected by a command
136so that it is easy to detect when a command has affected more lines
137than it should have.
138.PP
139The editor also normally prevents overwriting existing files unless you
140edited them so that you don't accidentally clobber
141with a
142.I write
143a file other than the one you are editing.
144If the system (or editor) crashes, or you accidentally hang up the phone,
145you can use the editor
146.B recover
147command to retrieve your work.
148This will get you back to within a few lines of where you left off.
149.PP
150.I Ex
151has several features for dealing with more than one file at a time.
152You can give it a list of files on the command line
153and use the
154.B next
155(\fBn\fR) command to deal with each in turn.
156The
157.B next
158command can also be given a list of file names, or a pattern
159as used by the shell to specify a new set of files to be dealt with.
160In general, filenames in the editor may be formed with full shell
161metasyntax.
162The metacharacter `%' is also available in forming filenames and is replaced
163by the name of the current file.
164For editing large groups of related files you can use
165.I ex's
166.B tag
167command to quickly locate functions and other important points in
168any of the files.
169This is useful when working on a large program when you want to quickly
170find the definition of a particular function.
171The command
172.IR ctags (UCB)
173builds a
174.I tags
175file or a group of C programs.
176.PP
177For moving text between files and within a file the editor has a group
178of buffers, named
179.I a
180through
181.I z.
182You can place text in these
183named buffers and carry it over when you edit another file.
184.PP
185There is a command
186.B &
187in
188.I ex
189which repeats the last
190.B substitute
191command.
192In addition there is a
193confirmed substitute command.
194You give a range of substitutions to be done and the editor interactively
195asks whether each substitution is desired.
196.PP
197You can use the
198.B substitute
199command in
200.I ex
201to systematically convert the case of letters between upper and lower case.
202It is possible to ignore case
203of letters in searches and substitutions.
204.I Ex
205also allows regular expressions which match words to be constructed.
206This is convenient, for example, in searching for the word
207``edit'' if your document also contains the word ``editor.''
208.PP
209.I Ex
210has a set of
211.I options
212which you can set to tailor it to your liking.
213One option which is very useful is the
214.I autoindent
215option which allows the editor to automatically supply leading white
216space to align text. You can then use the ^D key as a backtab
217and space and tab forward to align new code easily.
218.PP
219Miscellaneous new useful features include an intelligent
220.B join
221(\fBj\fR) command which supplies white space between joined lines
222automatically,
223commands < and > which shift groups of lines, and the ability to filter
224portions of the buffer through commands such as
225.I sort.
226.SH FILES
227.DT
228/usr/lib/ex2.0strings error messages
229.br
230/usr/lib/ex2.0recover recover command
231.br
232/usr/lib/ex2.0preserve preserve command
233.br
234/etc/termcap describes capabilities of terminals
235.br
236~/.exrc editor startup file
237.br
238/tmp/Ex\fInnnnn\fR editor temporary
239.br
240/tmp/Rx\fInnnnn\fR named buffer temporary
241.br
242/usr/preserve preservation directory
243.SH SEE ALSO
244awk(1), ed(1), grep(1), sed(1), edit(UCB), grep(UCB), termcap(UCB), vi(UCB)
245.SH AUTHOR
246William Joy
247.SH BUGS
248The
249.I undo
250command causes all marks to be lost on lines changed and then restored
251if the marked lines were changed.
252.PP
253.I Undo
254never clears the buffer modified condition.
255.PP
256The
257.I z
258command prints a number of logical rather than physical lines.
259More than a screen full of output may result if long lines are present.
260.PP
261File input/output errors don't print a name if the command line \fB`\-'\fR
262option is used.
263.PP
264There is no easy way to do a single scan ignoring case.
265.PP
266Because of the implementation of the arguments to
267.I next,
268only 512 bytes of argument list are allowed there.
269.PP
270The format of
271.I /etc/termcap
272and the large number of capabilities of terminals used by the editor
273cause terminal type setup to be rather slow.
274.PP
275The editor does not warn if text is placed in named buffers and not used
276before exiting the editor.
277.PP
278Null characters are discarded in input files, and cannot appear in resultant
279files.