edit(1) DG/UX 5.4R3.00 edit(1)
NAME
edit - text editor (variant of ex for casual users)
SYNOPSIS
edit [ -r ] [ -x ] [ -C ] name ...
DESCRIPTION
Edit is a variant of the text editor ex recommended for new or casual
users who wish to use a command-oriented editor. The following brief
introduction should help you get started with edit. If you are using
a CRT terminal you may want to learn about the display editor vi(1).
Options
-r Recover file after an editor or system crash. If file is not
specified, a list of all saved files will be printed.
-x Encryption option; when used, the file will be encrypted when
it is written and will require an encryption key to be read.
When reading a file, edit makes an educated guess as to
whether the file is encrypted or not. See crypt(1).
-C Encryption option; same as -x except that when reading in a
file, edit assumes that the file is encrypted.
Brief Introduction
To edit the contents of an existing file you begin with the command
"edit name" to the shell. Edit makes a copy of the file which you
can then edit, and tells you how many lines and characters are in the
file. To create a new file, just make up a name for the file and
invoke edit with the filename. If no file by that name already
exists, edit will create one and print [NEW FILE] on your screen.
Edit prompts for commands with the character `:', which you should
see after starting the editor. If you are editing an existing file,
then you will have some lines in edit's buffer (its name for the copy
of the file you are editing). Most commands to edit use its "current
line" if you do not tell them which line to use. When you invoke
edit for an existing file, the last line of the file is your current
line. If you type print (which can be abbreviated p) and press
Newline (as you should after all edit commands) the current line will
be printed. If you delete (d) the current line, edit will print the
new current line, which is typically the next line in the file. If
you delete this last line, then the new last line becomes the current
one. In general, after a delete, the next line in the file becomes
the current line. (Deleting the last line is a special case.)
If you start with an empty file or wish to add some new lines, then
the append (a) command can be used. After you give this command
(typing a Newline after the word append) edit will read lines from
your terminal until you give a line consisting of just a ".", placing
these lines after the current line. The last line you type then
becomes the current line. The command insert (i) is like append but
places the lines you give before, rather than after, the current
line.
Licensed material--property of copyright holder(s) 1
edit(1) DG/UX 5.4R3.00 edit(1)
Edit numbers the lines in the buffer, with the first line having
number 1. If you give the command "1" then edit will print this
first line. If you then give the command delete edit will delete the
first line, line 2 will become line 1, and edit will print the
current line (the new line 1) so you can see where you are. In
general, the current line will always be the last line affected by a
command.
You can make a change to some text within the current line by using
the substitute (s) command. You type "s/old/new/" where old is the
old characters you want to get rid of and new is the new characters
you want to replace old with.
The command file (f) will tell you how many lines there are in the
buffer you are editing and will print "[Modified]" if you have
changed the buffer. After modifying a file you can replace the file
with the buffer text by giving a write (w) command. You can then
leave the editor by issuing a quit (q) command. If you run edit on a
file, but do not change it, it is not necessary (but does no harm) to
write the file back. If you try to quit from edit after modifying
the buffer without writing it out, you will be warned that there has
been "No write since last change (:quit! overrides)" and edit will
await another command. If you wish not to write the buffer out then
you can issue another quit! command (note the exclamation point).
The buffer is then irretrievably discarded, and you return to the
shell.
By using the delete and append commands, and giving line numbers to
see lines in the file you can make any changes you desire. You
should learn at least a few more things, however, if you are to use
edit more than a few times.
The change (c) command will change the current line to a sequence of
lines you supply (as with append you add lines up to a line
consisting of only a "."). You can tell change to change more than
one line by giving the line numbers of the lines you want to change,
e.g., "3,5change". You can print lines this way too. Thus "1,23p"
prints the first 23 lines of the file.
The undo (u) command will reverse the effect of the last command you
gave which changed the buffer. Thus if you give a substitute command
which does not do what you want, you can type undo and the old
contents of the lines will be restored. You can also undo an undo
command so that you can continue to change your mind. Edit will give
you a warning message when your commands affect more than one line of
the buffer. If the amount of change seems unreasonable, you should
consider doing an undo and looking to see what happened. If you
decide that the change is ok, then you can type undo again to get it
back. Note that commands such as write and quit cannot be undone.
To look at the next line in the buffer you can just hit Newline. To
look at a number of lines type ^D (the control key and, while it is
held down, the D key, then let up both) rather than Newline. This
will show you a half screen of lines on a CRT or 12 lines on a
Licensed material--property of copyright holder(s) 2
edit(1) DG/UX 5.4R3.00 edit(1)
hardcopy terminal. You can look at the text around where you are by
giving the command "z.". The current line will then be the last line
printed; you can get back to the line where you were before the "z."
command by typing "''". The z command can also be given other
following characters: "z-" prints a screen of text (or 24 lines)
ending at the current line; "z+" prints the next screenful. If you
want less than a screenful of lines, type in "z.11" to get 11 lines
total (your former current line is now in the center of the 11 lines,
and the last line printed is your new current line). This method of
giving counts works in general; thus you can delete 5 lines starting
with the current line with the command "delete 5".
To find things in the file, you can use line numbers if you happen to
know them. However, since the line numbers change when you insert
and delete lines, this is somewhat unreliable. You can search
backwards and forwards in the file for strings by giving commands of
the form /text/ to search forward for text or ?text? to search
backward for text. If a search reaches the end of the file without
finding the text it wraps around to the other end of the file and
continues to search back to the line where you are. A useful feature
here is a search of the form /^text/ which searches for text at the
beginning of a line. Similarly /text$/ searches for text at the end
of a line. You can leave off the trailing / or ? in these commands.
The current line has a symbolic name "."; this is most useful in a
range of lines as in ".,$print" which prints the rest of the lines in
the file. To get to the last line in the file you can refer to it by
its symbolic name "$". Thus the command "$ delete" or "$d" deletes
the last line in the file, no matter which line was the current line
before. Arithmetic with line references is also possible. Thus the
line "$-5" is the fifth before the last, and ".+20" is 20 lines after
the current.
You can find out which line you are at by typing ".=". This is
useful if you wish to move or copy a section of text within a file or
between files. Find out the first and last line numbers you wish to
copy or move (e.g., 10 to 20). For a move you can then type
"10,20delete a" which deletes these lines from the file and places
them in a buffer named a. Edit has 26 such buffers named a through
z. You can later get these lines back by doing "put a" to put the
contents of buffer a after the current line. If you want to move or
copy these lines between files you can give an edit (e) command after
copying the lines, following it with the name of the other file you
wish to edit, e.g., "edit chapter2". By changing delete to yank
above you can get a command for copying lines. If the text you wish
to move or copy is all within one file then you can just type
"10,20move $" for example. It is not necessary to use named buffers
in this case (but you can if you wish).
SEE ALSO
ex(1), vi(1).
Licensed material--property of copyright holder(s) 3