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. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)ex.summary 8.3 (Berkeley) 8/18/96
30 .ds p \v'-0.2'.\v'+0.2'
32 .ds c \v'-0.2':\v'+0.2'
37 .ds LF Computing Services, U.C. Berkeley
48 Ex/Edit Command Summary (Version 2.0)
58 are text editors, used for creating
59 and modifying files of text on the \*U
64 with features designed to
65 make it less complicated
67 In terms of command syntax and effect
68 the editors are essentially identical,
69 and this command summary applies to both.
71 The summary is meant as a quick reference
72 for users already acquainted
76 Fuller explanations of the editors are available
81 (a self-teaching introduction) and the
85 (the comprehensive reference source for
86 both \fIedit\fP and \fIex\fP).
87 Both of these writeups are available in the
88 Computing Services Library.
90 In the examples included with the
91 summary, commands and text entered by
92 the user are printed in \fBboldface\fR to
93 distinguish them from responses printed
100 In order to perform its tasks
101 the editor sets aside a temporary
103 called a \fIbuffer\fR,
104 separate from the user's permanent
106 Before starting to work on an existing
107 file the editor makes a copy of it in the
108 buffer, leaving the original untouched.
109 All editing changes are made to the
110 buffer copy, which must then
111 be written back to the permanent
112 file in order to update the
114 The buffer disappears
115 at the end of the editing session.
119 Editing: Command and Text Input Modes
122 During an editing session there are
123 two usual modes of operation:
124 \fIcommand\fP mode and \fItext input\fP
126 (This disregards, for the moment,
130 modes, discussed below.)
131 In command mode, the editor issues a
133 to show that it is ready to
134 accept and execute a command.
135 In text input mode, on the other hand, there is
136 no prompt and the editor merely accepts text to
137 be added to the buffer.
138 Text input mode is initiated by the commands
139 \fIappend\fP, \fIinsert\fP, and \fIchange\fP,
140 and is terminated by typing a period as the
141 first and only character on a line.
145 Line Numbers and Command Syntax
148 The editor keeps track of lines of text
149 in the buffer by numbering them consecutively
150 starting with 1 and renumbering
151 as lines are added or deleted.
152 At any given time the editor is positioned
153 at one of these lines; this position is
154 called the \fIcurrent line\fP.
155 Generally, commands that change the
156 contents of the buffer print the
157 new current line at the end of their
160 Most commands can be preceded by one or two
161 line-number addresses which indicate the lines
163 If one number is given the command operates on
164 that line only; if two, on an inclusive range
166 Commands that can take line-number prefixes also
167 assume default prefixes if none are given.
168 The default assumed by each command is designed
169 to make it convenient to use in many instances
170 without any line-number prefix.
171 For the most part, a command used without a
172 prefix operates on the current line,
173 though exceptions to this rule should be noted.
174 The \fIprint\fP command
175 by itself, for instance, causes
176 one line, the current line, to be
177 printed at the terminal.
179 The summary shows the number of line addresses
181 prefixed to each command as well as
182 the defaults assumed if they are omitted.
185 means that up to 2 line-numbers may be given,
186 and that if none is given the
187 command operates on the current line.
188 (In the address prefix notation, ``.'' stands
189 for the current line and ``$'' stands for
190 the last line of the buffer.)
191 If no such notation appears, no
192 line-number prefix may be used.
194 Some commands take trailing
197 the more important instances of this
198 are mentioned in the summary.
202 Open and Visual Modes
205 Besides command and text input modes,
209 provide on some CRT terminals other modes of editing,
213 In these modes the cursor can
214 be moved to individual words
215 or characters in a line.
216 The commands then given are very different
217 from the standard editor commands; most do not appear on the screen when
220 An Introduction to Display Editing with Vi
222 provides a full discussion.
230 Some characters take on special meanings
231 when used in context searches
232 and in patterns given to the \fIsubstitute\fP command.
233 For \fIedit\fR, these are ``^'' and ``$'',
234 meaning the beginning and end of a line,
237 has the following additional special characters:
242 To use one of the special characters as its
243 simple graphic representation
244 rather than with its special meaning,
245 precede it by a backslash (\\).
246 The backslash always has a special meaning.
250 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
251 Name Abbr Description Examples
254 Begins text input mode,
255 adding lines to the buffer after
256 the line specified. Appending continues
257 until ``.'' is typed alone at the
258 beginning of a new line, followed by
259 a carriage return. \fI0a\fR places
260 lines at the beginning of the buffer.
265 are added to the buffer
266 after the current line.
273 \fR(.,.)\fBchange c T{
274 Deletes indicated line(s) and
275 initiates text input mode to
276 replace them with new text which follows.
277 New text is terminated the same way
278 as with \fIappend\fR.
283 deleted and replaced by
291 \fR(.,.)\fBcopy \fIaddr co T{
292 Places a copy of the specified lines
293 after the line indicated by \fIaddr\fR.
294 The example places a copy of lines 8 through
295 12, inclusive, after line 25.
299 \fRLast line copied is printed
304 \fR(.,.)\fBdelete d T{
305 Removes lines from the buffer
306 and prints the current line after the deletion.
310 \fRNew current line is printed
317 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
328 \fRClears the editor buffer and then
329 copies into it the named \fIfile\fR,
330 which becomes the current file.
331 This is a way of shifting to a different
333 without leaving the editor.
334 The editor issues a warning
335 message if this command is used before
337 made to the file already in the buffer;
338 using the form \fBe!\fR overrides this protective mechanism.
342 No write since last change
344 "ch10" 3 lines, 62 characters
349 \fBfile \fIname\fR f T{
350 \fRIf followed by a \fIname\fR, renames
351 the current file to \fIname\fR.
352 If used without \fIname\fR, prints
353 the name of the current file.
357 \fR"ch9" [Modified] 3 lines ...
359 \fR"ch9" [Modified] 3 lines ...
364 (1,$)\fBglobal g \fBglobal/\fIpattern\fB/\fIcommands T{
370 \fR(1,$)\fBglobal! g!\fR or \fBv T{
371 Searches the entire buffer (unless a smaller
372 range is specified by line-number prefixes) and
373 executes \fIcommands\fR on every line with
374 an expression matching \fIpattern\fR.
375 The second form, abbreviated
376 either \fBg!\fR or \fBv\fR,
377 executes \fIcommands\fR on lines that \fIdo
378 not\fR contain the expression \fIpattern\fR.
382 Inserts new lines of text immediately before the specified line.
385 only in that text is placed before, rather than after, the indicated line.
386 In other words, \fB1i\fR has the same effect as \fB0a\fR.
390 These lines of text will
391 be added prior to line 1.
397 \fR(.,.+1)\fBjoin j T{
398 Join lines together, adjusting white space (spaces
399 and tabs) as necessary.
403 Resulting line is printed
411 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
412 Name Abbr Description Examples
415 \fRPrints lines in a more
416 unambiguous way than the \fIprint\fR
417 command does. The end of a line,
418 for example, is marked with a ``$'',
419 and tabs printed as ``^I''.
430 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
431 \fR(.,.)\fBmove \fIaddr\fB m T{
432 \fRMoves the specified lines
433 to a position after the line
434 indicated by \fIaddr\fR.
438 New current line is printed
443 \fR(.,.)\fBnumber nu T{
444 Prints each line preceded
445 by its buffer line number.
449 \0\0\fR10\0 This is line 10
455 Too involved to discuss here,
456 but if you enter open mode
458 the \s-2ESC\s0 key followed by
460 get back into normal editor
462 \fIEdit\fP is designed to
463 prevent accidental use of
468 Saves a copy of the current buffer contents as though the system had
469 just crashed. This is for use in an emergency when a
471 command has failed and you don't know how else to save your work.\(dg
480 \fR(.,.)\fBprint p Prints the text of line(s). T{
483 The second and third lines
484 after the current line
491 \(dg You should seek assistance from a system administrator as soon as
492 possible after saving a file with the
494 command, because the preserved copy of the file is saved in a
495 directory used to store temporary files, and thus, the preserved
496 copy may only be available for a short period of time.
501 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
513 \fREnds the editing session.
515 warning if you have changed the buffer
516 since last writing its contents
517 to the file. In this event you
518 must either type \fBw\fR to write,
519 or type \fBq!\fR to exit from
520 the editor without saving your changes.
524 \fRNo write since last change
530 \fR(.)\fBread \fIfile\fP r T{
532 \fRPlaces a copy of \fIfile\fR in the
533 buffer after the specified line.
534 Address 0 is permissible and causes
535 the copy of \fIfile\fR to be placed
536 at the beginning of the buffer.
537 The \fIread\fP command does not
538 erase any text already in the buffer.
539 If no line number is specified,
540 \fIfile\fR is placed after the
545 \fR"newfile" 5 lines, 86 characters
550 \fBrecover \fIfile\fP rec T{
552 Retrieves a copy of the editor buffer
553 after a system crash, editor crash,
554 phone line disconnection, or
555 \fIpreserve\fR command.
558 \fR(.,.)\fBsubstitute s T{
560 \fBsubstitute/\fIpattern\fB/\fIreplacement\fB/
561 substitute/\fIpattern\fB/\fIreplacement\fB/gc
563 \fRReplaces the first occurrence of \fIpattern\fR
565 with \fIreplacement\fP.
566 Including a \fBg\fR after the command
567 changes all occurrences of \fIpattern\fP
569 The \fBc\fR option allows the user to
570 confirm each substitution before it is
571 made; see the manual for details.
575 \fRLine 3 contains a misstake
576 :\fBs/misstake/mistake/
577 \fRLine 3 contains a mistake
585 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
586 Name Abbr Description Examples
590 \fRReverses the changes made in
591 the buffer by the last buffer-editing
593 Note that this example contains
594 a notification about the number of
600 new line number 1 is printed
602 \fR15 more lines in file ...
603 old line number 1 is printed
608 \fR(1,$)\fBwrite \fIfile\fR w T{
610 \fRCopies data from the buffer onto
611 a permanent file. If no \fIfile\fR
612 is named, the current filename
614 The file is automatically created
615 if it does not yet exist.
616 A response containing the number of
617 lines and characters in the file
618 indicates that the write
619 has been completed successfully.
620 The editor's built-in protections
621 against overwriting existing files
622 will in some circumstances
624 The form \fBw!\fR forces the
625 write, confirming that
626 an existing file is to be overwritten.
630 \fR"file7" 64 lines, 1122 characters
632 \fR"file8" File exists ...
634 \fR"file8" 64 lines, 1122 characters
638 \fR(1,$)\fBwrite! \fIfile\fP w! \^ \^
642 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
643 \fR(.)\fBz \fIcount\fP z T{
645 \fRPrints a screen full of text starting
646 with the line indicated;
647 or, if \fIcount\fR is specified,
648 prints that number of lines.
649 Variants of the \fIz\fR command
650 are described in the manual.
655 Executes the remainder of the line
656 after \fB!\fR as a \*U command.
657 The buffer is unchanged by this, and
658 control is returned to the editor when
659 the execution of \fIcommand\fR is complete.
663 \fRFri Jun 9 12:15:11 PDT 1978
671 Prints the next \fIscroll\fR of text,
672 normally half of a screen. See the
673 manual for details of the \fIscroll\fR
679 An address alone followed by a carriage
680 return causes the line to be printed.
681 A carriage return by itself prints the
682 line following the current line.
686 the line after the current line
693 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
694 \fB/\fIpattern\fB/ T{
696 \fRSearches for the next line in which
697 \fIpattern\fR occurs and prints it.
700 \fR:\fB/This pattern/
701 \fRThis pattern next occurs here.
707 Repeats the most recent search.
711 \fRThis pattern also occurs here.
716 \fB?\fIpattern\fB? T{
717 Searches in the reverse direction
722 Repeats the most recent search,
723 moving in the reverse direction