1 .\" Copyright (c) 1980, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)ex.summary 8.3 (Berkeley) 8/18/96
34 .ds p \v'-0.2'.\v'+0.2'
36 .ds c \v'-0.2':\v'+0.2'
41 .ds LF Computing Services, U.C. Berkeley
52 Ex/Edit Command Summary (Version 2.0)
62 are text editors, used for creating
63 and modifying files of text on the \*U
68 with features designed to
69 make it less complicated
71 In terms of command syntax and effect
72 the editors are essentially identical,
73 and this command summary applies to both.
75 The summary is meant as a quick reference
76 for users already acquainted
80 Fuller explanations of the editors are available
85 (a self-teaching introduction) and the
89 (the comprehensive reference source for
90 both \fIedit\fP and \fIex\fP).
91 Both of these writeups are available in the
92 Computing Services Library.
94 In the examples included with the
95 summary, commands and text entered by
96 the user are printed in \fBboldface\fR to
97 distinguish them from responses printed
104 In order to perform its tasks
105 the editor sets aside a temporary
107 called a \fIbuffer\fR,
108 separate from the user's permanent
110 Before starting to work on an existing
111 file the editor makes a copy of it in the
112 buffer, leaving the original untouched.
113 All editing changes are made to the
114 buffer copy, which must then
115 be written back to the permanent
116 file in order to update the
118 The buffer disappears
119 at the end of the editing session.
123 Editing: Command and Text Input Modes
126 During an editing session there are
127 two usual modes of operation:
128 \fIcommand\fP mode and \fItext input\fP
130 (This disregards, for the moment,
134 modes, discussed below.)
135 In command mode, the editor issues a
137 to show that it is ready to
138 accept and execute a command.
139 In text input mode, on the other hand, there is
140 no prompt and the editor merely accepts text to
141 be added to the buffer.
142 Text input mode is initiated by the commands
143 \fIappend\fP, \fIinsert\fP, and \fIchange\fP,
144 and is terminated by typing a period as the
145 first and only character on a line.
149 Line Numbers and Command Syntax
152 The editor keeps track of lines of text
153 in the buffer by numbering them consecutively
154 starting with 1 and renumbering
155 as lines are added or deleted.
156 At any given time the editor is positioned
157 at one of these lines; this position is
158 called the \fIcurrent line\fP.
159 Generally, commands that change the
160 contents of the buffer print the
161 new current line at the end of their
164 Most commands can be preceded by one or two
165 line-number addresses which indicate the lines
167 If one number is given the command operates on
168 that line only; if two, on an inclusive range
170 Commands that can take line-number prefixes also
171 assume default prefixes if none are given.
172 The default assumed by each command is designed
173 to make it convenient to use in many instances
174 without any line-number prefix.
175 For the most part, a command used without a
176 prefix operates on the current line,
177 though exceptions to this rule should be noted.
178 The \fIprint\fP command
179 by itself, for instance, causes
180 one line, the current line, to be
181 printed at the terminal.
183 The summary shows the number of line addresses
185 prefixed to each command as well as
186 the defaults assumed if they are omitted.
189 means that up to 2 line-numbers may be given,
190 and that if none is given the
191 command operates on the current line.
192 (In the address prefix notation, ``.'' stands
193 for the current line and ``$'' stands for
194 the last line of the buffer.)
195 If no such notation appears, no
196 line-number prefix may be used.
198 Some commands take trailing
201 the more important instances of this
202 are mentioned in the summary.
206 Open and Visual Modes
209 Besides command and text input modes,
213 provide on some CRT terminals other modes of editing,
217 In these modes the cursor can
218 be moved to individual words
219 or characters in a line.
220 The commands then given are very different
221 from the standard editor commands; most do not appear on the screen when
224 An Introduction to Display Editing with Vi
226 provides a full discussion.
234 Some characters take on special meanings
235 when used in context searches
236 and in patterns given to the \fIsubstitute\fP command.
237 For \fIedit\fR, these are ``^'' and ``$'',
238 meaning the beginning and end of a line,
241 has the following additional special characters:
246 To use one of the special characters as its
247 simple graphic representation
248 rather than with its special meaning,
249 precede it by a backslash (\\).
250 The backslash always has a special meaning.
254 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
255 Name Abbr Description Examples
258 Begins text input mode,
259 adding lines to the buffer after
260 the line specified. Appending continues
261 until ``.'' is typed alone at the
262 beginning of a new line, followed by
263 a carriage return. \fI0a\fR places
264 lines at the beginning of the buffer.
269 are added to the buffer
270 after the current line.
277 \fR(.,.)\fBchange c T{
278 Deletes indicated line(s) and
279 initiates text input mode to
280 replace them with new text which follows.
281 New text is terminated the same way
282 as with \fIappend\fR.
287 deleted and replaced by
295 \fR(.,.)\fBcopy \fIaddr co T{
296 Places a copy of the specified lines
297 after the line indicated by \fIaddr\fR.
298 The example places a copy of lines 8 through
299 12, inclusive, after line 25.
303 \fRLast line copied is printed
308 \fR(.,.)\fBdelete d T{
309 Removes lines from the buffer
310 and prints the current line after the deletion.
314 \fRNew current line is printed
321 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
332 \fRClears the editor buffer and then
333 copies into it the named \fIfile\fR,
334 which becomes the current file.
335 This is a way of shifting to a different
337 without leaving the editor.
338 The editor issues a warning
339 message if this command is used before
341 made to the file already in the buffer;
342 using the form \fBe!\fR overrides this protective mechanism.
346 No write since last change
348 "ch10" 3 lines, 62 characters
353 \fBfile \fIname\fR f T{
354 \fRIf followed by a \fIname\fR, renames
355 the current file to \fIname\fR.
356 If used without \fIname\fR, prints
357 the name of the current file.
361 \fR"ch9" [Modified] 3 lines ...
363 \fR"ch9" [Modified] 3 lines ...
368 (1,$)\fBglobal g \fBglobal/\fIpattern\fB/\fIcommands T{
374 \fR(1,$)\fBglobal! g!\fR or \fBv T{
375 Searches the entire buffer (unless a smaller
376 range is specified by line-number prefixes) and
377 executes \fIcommands\fR on every line with
378 an expression matching \fIpattern\fR.
379 The second form, abbreviated
380 either \fBg!\fR or \fBv\fR,
381 executes \fIcommands\fR on lines that \fIdo
382 not\fR contain the expression \fIpattern\fR.
386 Inserts new lines of text immediately before the specified line.
389 only in that text is placed before, rather than after, the indicated line.
390 In other words, \fB1i\fR has the same effect as \fB0a\fR.
394 These lines of text will
395 be added prior to line 1.
401 \fR(.,.+1)\fBjoin j T{
402 Join lines together, adjusting white space (spaces
403 and tabs) as necessary.
407 Resulting line is printed
415 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
416 Name Abbr Description Examples
419 \fRPrints lines in a more
420 unambiguous way than the \fIprint\fR
421 command does. The end of a line,
422 for example, is marked with a ``$'',
423 and tabs printed as ``^I''.
434 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
435 \fR(.,.)\fBmove \fIaddr\fB m T{
436 \fRMoves the specified lines
437 to a position after the line
438 indicated by \fIaddr\fR.
442 New current line is printed
447 \fR(.,.)\fBnumber nu T{
448 Prints each line preceded
449 by its buffer line number.
453 \0\0\fR10\0 This is line 10
459 Too involved to discuss here,
460 but if you enter open mode
462 the \s-2ESC\s0 key followed by
464 get back into normal editor
466 \fIEdit\fP is designed to
467 prevent accidental use of
472 Saves a copy of the current buffer contents as though the system had
473 just crashed. This is for use in an emergency when a
475 command has failed and you don't know how else to save your work.\(dg
484 \fR(.,.)\fBprint p Prints the text of line(s). T{
487 The second and third lines
488 after the current line
495 \(dg You should seek assistance from a system administrator as soon as
496 possible after saving a file with the
498 command, because the preserved copy of the file is saved in a
499 directory used to store temporary files, and thus, the preserved
500 copy may only be available for a short period of time.
505 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
517 \fREnds the editing session.
519 warning if you have changed the buffer
520 since last writing its contents
521 to the file. In this event you
522 must either type \fBw\fR to write,
523 or type \fBq!\fR to exit from
524 the editor without saving your changes.
528 \fRNo write since last change
534 \fR(.)\fBread \fIfile\fP r T{
536 \fRPlaces a copy of \fIfile\fR in the
537 buffer after the specified line.
538 Address 0 is permissible and causes
539 the copy of \fIfile\fR to be placed
540 at the beginning of the buffer.
541 The \fIread\fP command does not
542 erase any text already in the buffer.
543 If no line number is specified,
544 \fIfile\fR is placed after the
549 \fR"newfile" 5 lines, 86 characters
554 \fBrecover \fIfile\fP rec T{
556 Retrieves a copy of the editor buffer
557 after a system crash, editor crash,
558 phone line disconnection, or
559 \fIpreserve\fR command.
562 \fR(.,.)\fBsubstitute s T{
564 \fBsubstitute/\fIpattern\fB/\fIreplacement\fB/
565 substitute/\fIpattern\fB/\fIreplacement\fB/gc
567 \fRReplaces the first occurrence of \fIpattern\fR
569 with \fIreplacement\fP.
570 Including a \fBg\fR after the command
571 changes all occurrences of \fIpattern\fP
573 The \fBc\fR option allows the user to
574 confirm each substitution before it is
575 made; see the manual for details.
579 \fRLine 3 contains a misstake
580 :\fBs/misstake/mistake/
581 \fRLine 3 contains a mistake
589 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
590 Name Abbr Description Examples
594 \fRReverses the changes made in
595 the buffer by the last buffer-editing
597 Note that this example contains
598 a notification about the number of
604 new line number 1 is printed
606 \fR15 more lines in file ...
607 old line number 1 is printed
612 \fR(1,$)\fBwrite \fIfile\fR w T{
614 \fRCopies data from the buffer onto
615 a permanent file. If no \fIfile\fR
616 is named, the current filename
618 The file is automatically created
619 if it does not yet exist.
620 A response containing the number of
621 lines and characters in the file
622 indicates that the write
623 has been completed successfully.
624 The editor's built-in protections
625 against overwriting existing files
626 will in some circumstances
628 The form \fBw!\fR forces the
629 write, confirming that
630 an existing file is to be overwritten.
634 \fR"file7" 64 lines, 1122 characters
636 \fR"file8" File exists ...
638 \fR"file8" 64 lines, 1122 characters
642 \fR(1,$)\fBwrite! \fIfile\fP w! \^ \^
646 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
647 \fR(.)\fBz \fIcount\fP z T{
649 \fRPrints a screen full of text starting
650 with the line indicated;
651 or, if \fIcount\fR is specified,
652 prints that number of lines.
653 Variants of the \fIz\fR command
654 are described in the manual.
659 Executes the remainder of the line
660 after \fB!\fR as a \*U command.
661 The buffer is unchanged by this, and
662 control is returned to the editor when
663 the execution of \fIcommand\fR is complete.
667 \fRFri Jun 9 12:15:11 PDT 1978
675 Prints the next \fIscroll\fR of text,
676 normally half of a screen. See the
677 manual for details of the \fIscroll\fR
683 An address alone followed by a carriage
684 return causes the line to be printed.
685 A carriage return by itself prints the
686 line following the current line.
690 the line after the current line
697 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
698 \fB/\fIpattern\fB/ T{
700 \fRSearches for the next line in which
701 \fIpattern\fR occurs and prints it.
704 \fR:\fB/This pattern/
705 \fRThis pattern next occurs here.
711 Repeats the most recent search.
715 \fRThis pattern also occurs here.
720 \fB?\fIpattern\fB? T{
721 Searches in the reverse direction
726 Repeats the most recent search,
727 moving in the reverse direction