2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright (c) 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH EDIT 1HAS "Jun 11, 2004"
9 edit \- text editor (variant of ex for casual users)
13 \fB/usr/bin/edit\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
14 [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
15 [+\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
20 \fB/usr/xpg4/bin/edit\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
21 [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
22 [+\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
27 \fB/usr/xpg6/bin/edit\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
28 [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
29 [+\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
35 The \fBedit\fR utility is a variant of the text editor \fBex\fR recommended for
36 new or casual users who wish to use a command-oriented editor. It operates
37 precisely as \fBex\fR with the following options automatically set:
76 The following brief introduction should help you get started with \fBedit\fR.
77 If you are using a \fBCRT\fR terminal you might want to learn about the display
81 To edit the contents of an existing file you begin with the command \fBedit
82 \fR\fIname\fR to the shell. \fBedit\fR makes a copy of the file that you can
83 then edit, and tells you how many lines and characters are in the file. To
84 create a new file, you also begin with the command \fBedit\fR with a filename:
85 \fBedit \fR\fIname\fR; the editor tells you it is a \fB[New File]\fR.
88 The \fBedit\fR command prompt is the colon (\fB:\fR), which you should see
89 after starting the editor. If you are editing an existing file, then you have
90 some lines in \fBedit\fR's buffer (its name for the copy of the file you are
91 editing). When you start editing, \fBedit\fR makes the last line of the file
92 the current line. Most commands to \fBedit\fR use the current line if you do
93 not tell them which line to use. Thus if you say \fBprint\fR (which can be
94 abbreviated \fBp\fR) and type carriage return (as you should after all
95 \fBedit\fR commands), the current line is printed. If you \fBdelete\fR
96 (\fBd\fR) the current line, \fBedit\fR prints the new current line, which is
97 usually the next line in the file. If you \fBdelete\fR the last line, then the
98 new last line becomes the current one.
101 If you start with an empty file or wish to add some new lines, then the
102 \fBappend\fR (\fBa\fR) command can be used. After you execute this command
103 (typing a carriage return after the word \fBappend\fR), \fBedit\fR reads lines
104 from your terminal until you type a line consisting of just a dot (\fB\&.\fR);
105 it places these lines after the current line. The last line you type then
106 becomes the current line. The \fBinsert\fR (\fBi\fR) command is like
107 \fBappend\fR, but places the lines you type before, rather than after, the
111 The \fBedit\fR utility numbers the lines in the buffer, with the first line
112 having number 1. If you execute the command \fB1\fR, then \fBedit\fR types the
113 first line of the buffer. If you then execute the command \fBd\fR, \fBedit\fR
114 deletes the first line, line 2 becomes line 1, and \fBedit\fR prints the
115 current line (the new line 1) so you can see where you are. In general, the
116 current line is always the last line affected by a command.
119 You can make a change to some text within the current line by using the
120 \fBsubstitute\fR (\fBs\fR) command: \fBs\fR/\fIold\fR\|/\fInew\fR/ where
121 \fIold\fR is the string of characters you want to replace and \fInew\fR is the
122 string of characters you want to replace \fIold\fR with.
125 The \fBfilename\fR (\fBf\fR) command tells you how many lines there are in the
126 buffer you are editing and says \fB[Modified]\fR if you have changed the
127 buffer. After modifying a file, you can save the contents of the file by
128 executing a \fBwrite\fR (\fBw\fR) command. You can leave the editor by issuing
129 a \fBquit\fR (\fBq\fR) command. If you run \fBedit\fR on a file, but do not
130 change it, it is not necessary (but does no harm) to \fBwrite\fR the file back.
131 If you try to \fBquit\fR from \fBedit\fR after modifying the buffer without
132 writing it out, you receive the message \fBNo write since last change (:quit!
133 overrides)\fR, and \fBedit\fR waits for another command. If you do not want to
134 write the buffer out, issue the \fBquit\fR command followed by an exclamation
135 point (\fBq!\fR). The buffer is then irretrievably discarded and you return to
139 By using the \fBd\fR and \fBa\fR commands and giving line numbers to see lines
140 in the file, you can make any changes you want. You should learn at least a few
141 more things, however, if you use \fBedit\fR more than a few times.
144 The \fBchange\fR (\fBc\fR) command changes the current line to a sequence of
145 lines you supply (as in \fBappend\fR, you type lines up to a line consisting of
146 only a dot (\fB\&.\fR). You can tell \fBchange\fR to change more than one line
147 by giving the line numbers of the lines you want to change, that is,
148 \fB3,5c\fR. You can print lines this way too: \fB1,23p\fR prints the first 23
152 The \fBundo\fR (\fBu\fR) command reverses the effect of the last command you
153 executed that changed the buffer. Thus if you execute a \fBsubstitute\fR
154 command that does not do what you want, type \fBu\fR and the old contents of
155 the line are restored. You can also \fBundo\fR an \fBundo\fR command.
156 \fBedit\fR gives you a warning message when a command affects more than one
157 line of the buffer. Note that commands such as \fBwrite\fR and \fBquit\fR
161 To look at the next line in the buffer, type carriage return. To look at a
162 number of lines, type \fB^D\fR (while holding down the control key, press
163 \fBd\fR) rather than carriage return. This shows you a half-screen of lines on
164 a \fBCRT\fR or 12 lines on a hardcopy terminal. You can look at nearby text by
165 executing the \fBz\fR command. The current line appears in the middle of the
166 text displayed, and the last line displayed becomes the current line; you can
167 get back to the line where you were before you executed the \fBz\fR command by
168 typing \fB\&''\fR. The \fBz\fR command has other options: \fBz\(mi\fR prints a
169 screen of text (or 24 lines) ending where you are; \fBz+\fR prints the next
170 screenful. If you want less than a screenful of lines, type \fBz.11\fR to
171 display five lines before and five lines after the current line. (Typing
172 \fBz.\fR\fIn\fR, when \fIn\fR is an odd number, displays a total of \fIn\fR
173 lines, centered about the current line; when \fIn\fR is an even number, it
174 displays \fIn\fR\fB-1\fR lines, so that the lines displayed are centered around
175 the current line.) You can give counts after other commands; for example, you
176 can delete 5 lines starting with the current line with the command \fBd5\fR.
179 To find things in the file, you can use line numbers if you happen to know
180 them; since the line numbers change when you insert and delete lines this is
181 somewhat unreliable. You can search backwards and forwards in the file for
182 strings by giving commands of the form /\fItext\fR/ to search forward for
183 \fItext\fR or ?\fItext\fR? to search backward for \fItext\fR. If a search
184 reaches the end of the file without finding \fItext\fR, it wraps around and
185 continues to search back to the line where you are. A useful feature here is a
186 search of the form /^\fItext\fR/ which searches for \fItext\fR at the beginning
187 of a line. Similarly /\fItext\fR$/ searches for \fItext\fR at the end of a
188 line. You can leave off the trailing \fB/\fR or \fB?\fR in these commands.
191 The current line has the symbolic name dot (\fB\&.\fR); this is most useful in
192 a range of lines as in \fB\&.,$p\fR which prints the current line plus the rest
193 of the lines in the file. To move to the last line in the file, you can refer
194 to it by its symbolic name $. Thus the command \fB$d\fR deletes the last line
195 in the file, no matter what the current line is. Arithmetic with line
196 references is also possible. Thus the line \fB$\fR\fB-5\fR is the fifth before
197 the last and \fB\&.+20\fR is 20 lines after the current line.
200 You can find out the current line by typing \fB`.='\fR\|. This is useful if you
201 wish to move or copy a section of text within a file or between files. Find the
202 first and last line numbers you wish to copy or move. To move lines 10 through
203 20, type \fB10,20d a\fR to delete these lines from the file and place them in a
204 buffer named \fBa\fR. \fBedit\fR has 26 such buffers named \fBa\fR through
205 \fBz\fR. To put the contents of buffer \fBa\fR after the current line, type
206 \fBput a\fR. If you want to move or copy these lines to another file, execute
207 an \fBedit\fR (\fBe\fR) command after copying the lines; following the \fBe\fR
208 command with the name of the other file you wish to edit, that is, \fBedit
209 chapter2\fR. To copy lines without deleting them, use \fByank\fR (\fBy\fR) in
210 place of \fBd\fR. If the text you wish to move or copy is all within one file,
211 it is not necessary to use named buffers. For example, to move lines 10 through
212 20 to the end of the file, type \fB10,20m $\fR.
216 These options can be turned on or off using the \fBset\fR command in
224 Encryption option; same as the \fB-x\fR option, except that \fBvi\fR simulates
225 the \fBC\fR command of \fBex\fR. The \fBC\fR command is like the \fBX\fR
226 command of \fBex\fR, except that all text read in is assumed to have been
236 Set up for editing LISP programs.
245 List the name of all files saved as the result of an editor or system crash.
254 \fBReadonly\fR mode; the \fBreadonly\fR flag is set, preventing accidental
255 overwriting of the file.
261 \fB\fB-r\fR\fI filename\fR\fR
264 Edit \fIfilename\fR after an editor or system crash. (Recovers the version of
265 \fIfilename\fR that was in the buffer when the crash occurred.)
271 \fB\fB-t\fR\fI tag\fR \fR
274 Edit the file containing the \fItag\fR and position the editor at its
284 Start up in display editing state using \fBvi\fR. You can achieve the same
285 effect by simply typing the \fBvi\fR command itself.
294 Verbose. When \fBex\fR commands are read by means of standard input, the input
295 is echoed to standard error. This can be useful when processing \fBex\fR
296 commands within shell scripts.
305 Encryption option; when used, \fBedit\fR simulates the \fBX\fR command of
306 \fBex\fR and prompts the user for a key. This key is used to encrypt and
307 decrypt text using the algorithm of the \fBcrypt\fR command. The \fBX\fR
308 command makes an educated guess to determine whether text read in is encrypted
309 or not. The temporary buffer file is encrypted also, using a transformed
310 version of the key typed in for the \fB-x\fR option.
316 \fB\fB-w\fR\fIn\fR\fR
319 Set the default window size to \fIn\fR. This is useful when using the editor
320 over a slow speed line.
326 \fB\fB+\fR\fIcommand\fR | \fB-c\fR\fI command\fR\fR
329 Begin editing by executing the specified editor \fBcommand\fR (usually a search
330 or positioning command).
336 \fB\fB\(mi\fR | \fB-s\fR \fR
339 Suppress all interactive user feedback. This is useful when processing editor
345 The \fIfilename\fR argument indicates one or more files to be edited.
349 See \fBattributes\fR(5) for descriptions of the following attributes:
358 ATTRIBUTE TYPE ATTRIBUTE VALUE
363 .SS "/usr/xpg4/bin/edit"
371 ATTRIBUTE TYPE ATTRIBUTE VALUE
376 .SS "/usr/xpg6/bin/edit"
384 ATTRIBUTE TYPE ATTRIBUTE VALUE
392 \fBed\fR(1), \fBex\fR(1), \fBvi\fR(1), \fBattributes\fR(5), \fBXPG4\fR(5)
396 The encryption options are provided with the Security Administration Utilities
397 package, which is available only in the United States.