home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
- Ex/Edit Command Summary (Version 2.0)
- Ex and edit are text edi- visual modes, discussed below.)
- tors, used for creating and In command mode, the editor
- modifying files of text on the issues a colon prompt (:) to
- UNIX computer system. Edit is show that it is ready to accept
- a variant of ex with features and execute a command. In text
- designed to make it less com- input mode, on the other hand,
- plicated to learn and use. In there is no prompt and the edi-
- terms of command syntax and tor merely accepts text to be
- effect the editors are essen- added to the buffer. Text
- tially identical, and this com- input mode is initiated by the
- mand summary applies to both. commands append, insert, and
- The summary is meant as a change, and is terminated by
- quick reference for users typing a period as the first
- already acquainted with edit or and only character on a line.
- ex. Fuller explanations of the Line Numbers and Command Syntax
- editors are available in the The editor keeps track of
- documents Edit: A Tutorial (a lines of text in the buffer by
- self-teaching introduction) and numbering them consecutively
- the Ex Reference Manual (the starting with 1 and renumbering
- comprehensive reference source as lines are added or deleted.
- for both edit and ex). Both of At any given time the editor is
- these writeups are available in positioned at one of these
- the Computing Services Library. lines; this position is called
- In the examples included the current line. Generally,
- with the summary, commands and commands that change the con-
- text entered by the user are tents of the buffer print the
- printed in boldface to distin- new current line at the end of
- guish them from responses their execution.
- printed by the computer. Most commands can be pre-
- The Editor Buffer ceded by one or two line-number
- In order to perform its addresses which indicate the
- tasks the editor sets aside a lines to be affected. If one
- temporary work space, called a number is given the command
- buffer, separate from the operates on that line only; if
- user's permanent file. Before two, on an inclusive range of
- starting to work on an existing lines. Commands that can take
- file the editor makes a copy of line-number prefixes also
- it in the buffer, leaving the assume default prefixes if none
- original untouched. All edit- are given. The default assumed
- ing changes are made to the by each command is designed to
- buffer copy, which must then be make it convenient to use in
- written back to the permanent many instances without any
- file in order to update the old line-number prefix. For the
- version. The buffer disappears most part, a command used with-
- at the end of the editing ses- out a prefix operates on the
- sion. current line, though exceptions
- Editing: Command and Text Input to this rule should be noted.
- Modes The print command by itself,
- During an editing session for instance, causes one line,
- there are two usual modes of the current line, to be printed
- operation: command mode and at the terminal.
- text input mode. (This disre- The summary shows the number
- gards, for the moment, open and of line addresses that can be
-
-
-
- Computing Services, U.C. Berkeley April 3, 1979
-
-
-
-
-
- prefixed to each command as
- well as the defaults assumed if
- they are omitted. For example,
- (.,.) means that up to 2 line-
- numbers may be given, and that
- if none is given the command
- operates on the current line.
- (In the address prefix nota-
- tion, ``.'' stands for the cur-
- rent line and ``$'' stands for
- the last line of the buffer.)
- If no such notation appears, no
- line-number prefix may be used.
- Some commands take trailing
- information; only the more
- important instances of this are
- mentioned in the summary.
- Open and Visual Modes
- Besides command and text
- input modes, ex and edit pro-
- vide on some CRT terminals
- other modes of editing, open
- and visual. In these modes the
- cursor can be moved to individ-
- ual words or characters in a
- line. The commands then given
- are very different from the
- standard editor commands; most
- do not appear on the screen
- when typed. An Introduction to
- Display Editing with Vi pro-
- vides a full discussion.
- Special Characters
- Some characters take on spe-
- cial meanings when used in con-
- text searches and in patterns
- given to the substitute com-
- mand. For edit, these are
- ``^'' and ``$'', meaning the
- beginning and end of a line,
- respectively. Ex has the fol-
- lowing additional special char-
- acters:
- . & * [ ] ~
- To use one of the special char-
- acters as its simple graphic
- representation rather than with
- its special meaning, precede it
- by a backslash (\). The back-
- slash always has a special
- meaning.
-
-
-
-
-
-
-
-
-
- Computing Services, U.C. Berkeley April 3, 1979
-
-
-
-
-
- cp10 cp10 cp10 cp10 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
- Name Abbr Description Examples
-
-
- (.)append a T{ Begins text input mode, adding lines to the
- buffer after the line specified. Appending continues until ``.'' is
- typed alone at the beginning of a new line, followed by a carriage
- return. 0a places lines at the beginning of the buffer. T} T{
- :a
- Three lines of text
- are added to the buffer
- after the current line.
- .
- :
- T}
-
- (.,.)change c T{ Deletes indicated line(s) and initiates text
- input mode to replace them with new text which follows. New text
- is terminated the same way as with append. T} T{
- :5,6c
- Lines 5 and 6 are
- deleted and replaced by
- these three lines.
- .
- :
- T}
-
- (.,.)copy addr co T{ Places a copy of the specified lines after
- the line indicated by addr. The example places a copy of lines 8
- through 12, inclusive, after line 25. T} T{
- :8,12co 25
- Last line copied is printed
- :
- T}
-
- (.,.)delete d T{ Removes lines from the buffer and prints the
- current line after the deletion. T} T{
- :13,15d
- New current line is printed
- :
- T}
-
-
- ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i). T{ edit file
- edit! file T} T{ e
- e! T} T{
- Clears the editor buffer and then copies into it the named file,
- which becomes the current file. This is a way of shifting to a
- different file without leaving the editor. The editor issues a
- warning message if this command is used before saving changes made
- to the file already in the buffer; using the form e! overrides this
- protective mechanism. T} T{
- :e ch10
- No write since last change
- :e! ch10
- "ch10" 3 lines, 62 characters
- :
-
-
-
-
-
-
-
-
-
- T}
-
- file name f T{ If followed by a name, renames the current file
- to name. If used without name, prints the name of the current
- file. T} T{
- :f ch9
- "ch9" [Modified] 3 lines ...
- :f
- "ch9" [Modified] 3 lines ...
- :
- T}
-
- (1,$)global g global/pattern/commands T{
- :g/nonsense/d
- :
- T} (1,$)global! g! or v T{ Searches the entire buffer (unless a
- smaller range is specified by line-number prefixes) and executes
- commands on every line with an expression matching pattern. The
- second form, abbreviated either g! or v, executes commands on lines
- that do not contain the expression pattern. T}
-
- (.)insert i T{ Inserts new lines of text immediately before the
- specified line. Differs from append only in that text is placed
- before, rather than after, the indicated line. In other words, 1i
- has the same effect as 0a. T} T{
- :1i
- These lines of text will
- be added prior to line 1.
- .
- :
- T}
-
- (.,.+1)join j T{ Join lines together, adjusting white space
- (spaces and tabs) as necessary. T} T{
- :2,5j
- Resulting line is printed
- :
- T}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- cp10 cp10 cp10 cp10 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
- Name Abbr Description Examples
-
-
- (.,.)list l T{ Prints lines in a more unambiguous way than the
- print command does. The end of a line, for example, is marked with
- a ``$'', and tabs printed as ``^I''. T} T{
- :9l
- This is line 9$
- :
- T}
-
-
- ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i). (.,.)move
- addr m T{ Moves the specified lines to a position after the line
- indicated by addr. T} T{
- :12,15m 25
- New current line is printed
- :
- T}
-
- (.,.)number nu T{ Prints each line preceded by its buffer line
- number. T} T{
- :nu
- 10 This is line 10
- :
- T}
-
- (.)open o T{ Too involved to discuss here, but if you enter
- open mode accidentally, press the ESC key followed by q to get back
- into normal editor command mode. Edit is designed to prevent acci-
- dental use of the open command. T}
-
- preserve pre T{ Saves a copy of the current buffer contents as
- though the system had just crashed. This is for use in an emer-
- gency when a write command has failed and you don't know how else
- to save your work.- T} T{
- :preserve
- File preserved.
- :
- T}
-
- (.,.)print p Prints the text of line(s). T{
- :+2,+3p
- The second and third lines
- after the current line
- :
- T}
-
-
-
- ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
- T{
- quit
- quit!
- T} T{
- q
- q!
- -----------
- - Seek assistance from a consultant as soon as possible
- after saving a file with the preserve command, because
- the file is saved on system storage space for only one
- week.
-
-
-
- T} T{
- Ends the editing session. You will receive a warning if you have
- changed the buffer since last writing its contents to the file. In
- this event you must either type w to write, or type q! to exit from
- the editor without saving your changes. T} T{
- :q
- No write since last change
- :q!
- %
- T}
-
- (.)read file r T{
- Places a copy of file in the buffer after the specified line.
- Address 0 is permissible and causes the copy of file to be placed
- at the beginning of the buffer. The read command does not erase
- any text already in the buffer. If no line number is specified,
- file is placed after the current line. T} T{
- :0r newfile
- "newfile" 5 lines, 86 characters
- :
- T}
-
- recover file rec T{
- Retrieves a copy of the editor buffer after a system crash, editor
- crash, phone line disconnection, or preserve command. T}
-
- (.,.)substitute s T{
- substitute/pattern/replacement/
- substitute/pattern/replacement/gc
- Replaces the first occurrence of pattern on a line with replace-
- ment. Including a g after the command changes all occurrences of
- pattern on the line. The c option allows the user to confirm each
- substitution before it is made; see the manual for details.
- T} T{
- :3p
- Line 3 contains a misstake
- :s/misstake/mistake/
- Line 3 contains a mistake
- :
- T}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- cp10 cp10 cp10 cp10 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
- Name Abbr Description Examples
-
-
- undo u T{
- Reverses the changes made in the buffer by the last buffer-editing
- command. Note that this example contains a notification about the
- number of lines affected. T} T{
- :1,15d
- 15 lines deleted
- new line number 1 is printed
- :u
- 15 more lines in file ...
- old line number 1 is printed
- :
- T}
-
- (1,$)write file w T{
- Copies data from the buffer onto a permanent file. If no file is
- named, the current filename is used. The file is automatically
- created if it does not yet exist. A response containing the number
- of lines and characters in the file indicates that the write has
- been completed successfully. The editor's built-in protections
- against overwriting existing files will in some circumstances
- inhibit a write. The form w! forces the write, confirming that an
- existing file is to be overwritten. T} T{
- :w
- "file7" 64 lines, 1122 characters
- :w file8
- "file8" File exists ...
- :w! file8
- "file8" 64 lines, 1122 characters
- :
- T} (1,$)write! file w!
-
-
- ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i). (.)z
- count z T{
- Prints a screen full of text starting with the line indicated; or,
- if count is specified, prints that number of lines. Variants of
- the z command are described in the manual. T}
-
- !command T{
- Executes the remainder of the line after ! as a UNIX command. The
- buffer is unchanged by this, and control is returned to the editor
- when the execution of command is complete. T} T{
- :!date
- Fri Jun 9 12:15:11 PDT 1978
- !
- :
- T}
-
- control-d T{
- Prints the next scroll of text, normally half of a screen. See the
- manual for details of the scroll option. T}
-
- (.+1)<cr> T{
- An address alone followed by a carriage return causes the line to
- be printed. A carriage return by itself prints the line following
- the current line. T} T{
- :<cr>
- the line after the current line
- :
-
-
-
- T}
-
-
- ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i). /pattern/ T{
- Searches for the next line in which pattern occurs and prints it.
- T} T{
- :/This pattern/
- This pattern next occurs here.
- :
- T}
-
- // T{ Repeats the most recent search. T} T{
- ://
- This pattern also occurs here.
- :
- T}
-
- ?pattern? T{ Searches in the reverse direction for pattern.
- T}
-
- ?? T{ Repeats the most recent search, moving in the reverse
- direction through the buffer. T}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-