1edit(1) User Commands edit(1)
2
3
4
6 edit - text editor (variant of ex for casual users)
7
9 /usr/bin/edit [-| -s] [-l] [-L] [-R] [-r [filename]]
10 [-t tag] [-v] [-V] [-x] [-wn] [-C]
11 [+command | -c command] filename...
12
13
14 /usr/xpg4/bin/edit [-| -s] [-l] [-L] [-R] [-r [filename]]
15 [-t tag] [-v] [-V] [-x] [-wn] [-C]
16 [+command | -c command] filename...
17
18
19 /usr/xpg6/bin/edit [-| -s] [-l] [-L] [-R] [-r [filename]]
20 [-t tag] [-v] [-V] [-x] [-wn] [-C]
21 [+command | -c command] filename...
22
23
25 The edit utility is a variant of the text editor ex recommended for new
26 or casual users who wish to use a command-oriented editor. It operates
27 precisely as ex with the following options automatically set:
28
29 novice ON
30
31
32 report ON
33
34
35 showmode ON
36
37
38 magic OFF
39
40
41
42 The following brief introduction should help you get started with edit.
43 If you are using a CRT terminal you might want to learn about the dis‐
44 play editor vi.
45
46
47 To edit the contents of an existing file you begin with the command
48 edit name to the shell. edit makes a copy of the file that you can then
49 edit, and tells you how many lines and characters are in the file. To
50 create a new file, you also begin with the command edit with a file‐
51 name: edit name; the editor tells you it is a [New File].
52
53
54 The edit command prompt is the colon (:), which you should see after
55 starting the editor. If you are editing an existing file, then you have
56 some lines in edit's buffer (its name for the copy of the file you are
57 editing). When you start editing, edit makes the last line of the file
58 the current line. Most commands to edit use the current line if you do
59 not tell them which line to use. Thus if you say print (which can be
60 abbreviated p) and type carriage return (as you should after all edit
61 commands), the current line is printed. If you delete (d) the current
62 line, edit prints the new current line, which is usually the next line
63 in the file. If you delete the last line, then the new last line
64 becomes the current one.
65
66
67 If you start with an empty file or wish to add some new lines, then the
68 append (a) command can be used. After you execute this command (typing
69 a carriage return after the word append), edit reads lines from your
70 terminal until you type a line consisting of just a dot (.); it places
71 these lines after the current line. The last line you type then becomes
72 the current line. The insert (i) command is like append, but places the
73 lines you type before, rather than after, the current line.
74
75
76 The edit utility numbers the lines in the buffer, with the first line
77 having number 1. If you execute the command 1, then edit types the
78 first line of the buffer. If you then execute the command d, edit
79 deletes the first line, line 2 becomes line 1, and edit prints the cur‐
80 rent line (the new line 1) so you can see where you are. In general,
81 the current line is always the last line affected by a command.
82
83
84 You can make a change to some text within the current line by using the
85 substitute (s) command: s/old/new/ where old is the string of charac‐
86 ters you want to replace and new is the string of characters you want
87 to replace old with.
88
89
90 The filename (f) command tells you how many lines there are in the buf‐
91 fer you are editing and says [Modified] if you have changed the buffer.
92 After modifying a file, you can save the contents of the file by exe‐
93 cuting a write (w) command. You can leave the editor by issuing a quit
94 (q) command. If you run edit on a file, but do not change it, it is not
95 necessary (but does no harm) to write the file back. If you try to quit
96 from edit after modifying the buffer without writing it out, you
97 receive the message No write since last change (:quit! overrides), and
98 edit waits for another command. If you do not want to write the buffer
99 out, issue the quit command followed by an exclamation point (q!). The
100 buffer is then irretrievably discarded and you return to the shell.
101
102
103 By using the d and a commands and giving line numbers to see lines in
104 the file, you can make any changes you want. You should learn at least
105 a few more things, however, if you use edit more than a few times.
106
107
108 The change (c) command changes the current line to a sequence of lines
109 you supply (as in append, you type lines up to a line consisting of
110 only a dot (.). You can tell change to change more than one line by
111 giving the line numbers of the lines you want to change, that is, 3,5c.
112 You can print lines this way too: 1,23p prints the first 23 lines of
113 the file.
114
115
116 The undo (u) command reverses the effect of the last command you exe‐
117 cuted that changed the buffer. Thus if you execute a substitute command
118 that does not do what you want, type u and the old contents of the line
119 are restored. You can also undo an undo command. edit gives you a warn‐
120 ing message when a command affects more than one line of the buffer.
121 Note that commands such as write and quit cannot be undone.
122
123
124 To look at the next line in the buffer, type carriage return. To look
125 at a number of lines, type ^D (while holding down the control key,
126 press d) rather than carriage return. This shows you a half-screen of
127 lines on a CRT or 12 lines on a hardcopy terminal. You can look at
128 nearby text by executing the z command. The current line appears in the
129 middle of the text displayed, and the last line displayed becomes the
130 current line; you can get back to the line where you were before you
131 executed the z command by typing ''. The z command has other options:
132 z− prints a screen of text (or 24 lines) ending where you are; z+
133 prints the next screenful. If you want less than a screenful of lines,
134 type z.11 to display five lines before and five lines after the cur‐
135 rent line. (Typing z.n, when n is an odd number, displays a total of n
136 lines, centered about the current line; when n is an even number, it
137 displays n-1 lines, so that the lines displayed are centered around the
138 current line.) You can give counts after other commands; for example,
139 you can delete 5 lines starting with the current line with the command
140 d5.
141
142
143 To find things in the file, you can use line numbers if you happen to
144 know them; since the line numbers change when you insert and delete
145 lines this is somewhat unreliable. You can search backwards and for‐
146 wards in the file for strings by giving commands of the form /text/ to
147 search forward for text or ?text? to search backward for text. If a
148 search reaches the end of the file without finding text, it wraps
149 around and continues to search back to the line where you are. A useful
150 feature here is a search of the form /^text/ which searches for text at
151 the beginning of a line. Similarly /text$/ searches for text at the end
152 of a line. You can leave off the trailing / or ? in these commands.
153
154
155 The current line has the symbolic name dot (.); this is most useful in
156 a range of lines as in .,$p which prints the current line plus the rest
157 of the lines in the file. To move to the last line in the file, you can
158 refer to it by its symbolic name $. Thus the command $d deletes the
159 last line in the file, no matter what the current line is. Arithmetic
160 with line references is also possible. Thus the line $-5 is the fifth
161 before the last and .+20 is 20 lines after the current line.
162
163
164 You can find out the current line by typing `.='. This is useful if you
165 wish to move or copy a section of text within a file or between files.
166 Find the first and last line numbers you wish to copy or move. To move
167 lines 10 through 20, type 10,20d a to delete these lines from the file
168 and place them in a buffer named a. edit has 26 such buffers named a
169 through z. To put the contents of buffer a after the current line, type
170 put a. If you want to move or copy these lines to another file, execute
171 an edit (e) command after copying the lines; following the e command
172 with the name of the other file you wish to edit, that is, edit chap‐
173 ter2. To copy lines without deleting them, use yank (y) in place of d.
174 If the text you wish to move or copy is all within one file, it is not
175 necessary to use named buffers. For example, to move lines 10 through
176 20 to the end of the file, type 10,20m $.
177
179 These options can be turned on or off using the set command in ex(1).
180
181 -C Encryption option; same as the -x option,
182 except that vi simulates the C command of ex.
183 The C command is like the X command of ex,
184 except that all text read in is assumed to
185 have been encrypted.
186
187
188 -l Set up for editing LISP programs.
189
190
191 -L List the name of all files saved as the
192 result of an editor or system crash.
193
194
195 -R Readonly mode; the readonly flag is set, pre‐
196 venting accidental overwriting of the file.
197
198
199 -r filename Edit filename after an editor or system
200 crash. (Recovers the version of filename that
201 was in the buffer when the crash occurred.)
202
203
204 -t tag Edit the file containing the tag and position
205 the editor at its definition.
206
207
208 -v Start up in display editing state using vi.
209 You can achieve the same effect by simply
210 typing the vi command itself.
211
212
213 -V Verbose. When ex commands are read by means
214 of standard input, the input is echoed to
215 standard error. This can be useful when pro‐
216 cessing ex commands within shell scripts.
217
218
219 -x Encryption option; when used, edit simulates
220 the X command of ex and prompts the user for
221 a key. This key is used to encrypt and
222 decrypt text using the algorithm of the crypt
223 command. The X command makes an educated
224 guess to determine whether text read in is
225 encrypted or not. The temporary buffer file
226 is encrypted also, using a transformed ver‐
227 sion of the key typed in for the -x option.
228
229
230 -wn Set the default window size to n. This is
231 useful when using the editor over a slow
232 speed line.
233
234
235 +command | -c command Begin editing by executing the specified edi‐
236 tor command (usually a search or positioning
237 command).
238
239
240 − | -s Suppress all interactive user feedback. This
241 is useful when processing editor scripts.
242
243
244
245 The filename argument indicates one or more files to be edited.
246
248 See attributes(5) for descriptions of the following attributes:
249
250 /usr/bin/edit
251 ┌───────────────────────────────────────────────────────────┐
252 │ATTRIBUTE TYPE ATTRIBUTE VALUE │
253 │Availability SUNWcsu │
254 │CSI Enabled │
255 └───────────────────────────────────────────────────────────┘
256
257 /usr/xpg4/bin/edit
258 ┌───────────────────────────────────────────────────────────┐
259 │ATTRIBUTE TYPE ATTRIBUTE VALUE │
260 │Availability SUNWxcu4 │
261 │CSI Enabled │
262 └───────────────────────────────────────────────────────────┘
263
264 /usr/xpg6/bin/edit
265 ┌───────────────────────────────────────────────────────────┐
266 │ATTRIBUTE TYPE ATTRIBUTE VALUE │
267 │Availability SUNWxcu6 │
268 │CSI Enabled │
269 └───────────────────────────────────────────────────────────┘
270
272 ed(1), ex(1), vi(1), attributes(5), XPG4(5)
273
275 The encryption options are provided with the Security Administration
276 Utilities package, which is available only in the United States.
277
278
279
280SunOS 5.11 11 Jun 2004 edit(1)