1 .\" Copyright (c) 1980, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" %sccs.include.redist.roff%
6 .\" $Id: ex.summary,v 8.3 1996/08/18 11:36:16 bostic Exp $ (Berkeley) $Date: 1996/08/18 11:36:16 $
8 .ds p \v'-0.2'.\v'+0.2'
10 .ds c \v'-0.2':\v'+0.2'
15 .ds LF Computing Services, U.C. Berkeley
26 Ex/Edit Command Summary (Version 2.0)
36 are text editors, used for creating
37 and modifying files of text on the \*U
42 with features designed to
43 make it less complicated
45 In terms of command syntax and effect
46 the editors are essentially identical,
47 and this command summary applies to both.
49 The summary is meant as a quick reference
50 for users already acquainted
54 Fuller explanations of the editors are available
59 (a self-teaching introduction) and the
63 (the comprehensive reference source for
64 both \fIedit\fP and \fIex\fP).
65 Both of these writeups are available in the
66 Computing Services Library.
68 In the examples included with the
69 summary, commands and text entered by
70 the user are printed in \fBboldface\fR to
71 distinguish them from responses printed
78 In order to perform its tasks
79 the editor sets aside a temporary
81 called a \fIbuffer\fR,
82 separate from the user's permanent
84 Before starting to work on an existing
85 file the editor makes a copy of it in the
86 buffer, leaving the original untouched.
87 All editing changes are made to the
88 buffer copy, which must then
89 be written back to the permanent
90 file in order to update the
93 at the end of the editing session.
97 Editing: Command and Text Input Modes
100 During an editing session there are
101 two usual modes of operation:
102 \fIcommand\fP mode and \fItext input\fP
104 (This disregards, for the moment,
108 modes, discussed below.)
109 In command mode, the editor issues a
111 to show that it is ready to
112 accept and execute a command.
113 In text input mode, on the other hand, there is
114 no prompt and the editor merely accepts text to
115 be added to the buffer.
116 Text input mode is initiated by the commands
117 \fIappend\fP, \fIinsert\fP, and \fIchange\fP,
118 and is terminated by typing a period as the
119 first and only character on a line.
123 Line Numbers and Command Syntax
126 The editor keeps track of lines of text
127 in the buffer by numbering them consecutively
128 starting with 1 and renumbering
129 as lines are added or deleted.
130 At any given time the editor is positioned
131 at one of these lines; this position is
132 called the \fIcurrent line\fP.
133 Generally, commands that change the
134 contents of the buffer print the
135 new current line at the end of their
138 Most commands can be preceded by one or two
139 line-number addresses which indicate the lines
141 If one number is given the command operates on
142 that line only; if two, on an inclusive range
144 Commands that can take line-number prefixes also
145 assume default prefixes if none are given.
146 The default assumed by each command is designed
147 to make it convenient to use in many instances
148 without any line-number prefix.
149 For the most part, a command used without a
150 prefix operates on the current line,
151 though exceptions to this rule should be noted.
152 The \fIprint\fP command
153 by itself, for instance, causes
154 one line, the current line, to be
155 printed at the terminal.
157 The summary shows the number of line addresses
159 prefixed to each command as well as
160 the defaults assumed if they are omitted.
163 means that up to 2 line-numbers may be given,
164 and that if none is given the
165 command operates on the current line.
166 (In the address prefix notation, ``.'' stands
167 for the current line and ``$'' stands for
168 the last line of the buffer.)
169 If no such notation appears, no
170 line-number prefix may be used.
172 Some commands take trailing
175 the more important instances of this
176 are mentioned in the summary.
180 Open and Visual Modes
183 Besides command and text input modes,
187 provide on some CRT terminals other modes of editing,
191 In these modes the cursor can
192 be moved to individual words
193 or characters in a line.
194 The commands then given are very different
195 from the standard editor commands; most do not appear on the screen when
198 An Introduction to Display Editing with Vi
200 provides a full discussion.
208 Some characters take on special meanings
209 when used in context searches
210 and in patterns given to the \fIsubstitute\fP command.
211 For \fIedit\fR, these are ``^'' and ``$'',
212 meaning the beginning and end of a line,
215 has the following additional special characters:
220 To use one of the special characters as its
221 simple graphic representation
222 rather than with its special meaning,
223 precede it by a backslash (\\).
224 The backslash always has a special meaning.
228 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
229 Name Abbr Description Examples
232 Begins text input mode,
233 adding lines to the buffer after
234 the line specified. Appending continues
235 until ``.'' is typed alone at the
236 beginning of a new line, followed by
237 a carriage return. \fI0a\fR places
238 lines at the beginning of the buffer.
243 are added to the buffer
244 after the current line.
251 \fR(.,.)\fBchange c T{
252 Deletes indicated line(s) and
253 initiates text input mode to
254 replace them with new text which follows.
255 New text is terminated the same way
256 as with \fIappend\fR.
261 deleted and replaced by
269 \fR(.,.)\fBcopy \fIaddr co T{
270 Places a copy of the specified lines
271 after the line indicated by \fIaddr\fR.
272 The example places a copy of lines 8 through
273 12, inclusive, after line 25.
277 \fRLast line copied is printed
282 \fR(.,.)\fBdelete d T{
283 Removes lines from the buffer
284 and prints the current line after the deletion.
288 \fRNew current line is printed
295 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
306 \fRClears the editor buffer and then
307 copies into it the named \fIfile\fR,
308 which becomes the current file.
309 This is a way of shifting to a different
311 without leaving the editor.
312 The editor issues a warning
313 message if this command is used before
315 made to the file already in the buffer;
316 using the form \fBe!\fR overrides this protective mechanism.
320 No write since last change
322 "ch10" 3 lines, 62 characters
327 \fBfile \fIname\fR f T{
328 \fRIf followed by a \fIname\fR, renames
329 the current file to \fIname\fR.
330 If used without \fIname\fR, prints
331 the name of the current file.
335 \fR"ch9" [Modified] 3 lines ...
337 \fR"ch9" [Modified] 3 lines ...
342 (1,$)\fBglobal g \fBglobal/\fIpattern\fB/\fIcommands T{
348 \fR(1,$)\fBglobal! g!\fR or \fBv T{
349 Searches the entire buffer (unless a smaller
350 range is specified by line-number prefixes) and
351 executes \fIcommands\fR on every line with
352 an expression matching \fIpattern\fR.
353 The second form, abbreviated
354 either \fBg!\fR or \fBv\fR,
355 executes \fIcommands\fR on lines that \fIdo
356 not\fR contain the expression \fIpattern\fR.
360 Inserts new lines of text immediately before the specified line.
363 only in that text is placed before, rather than after, the indicated line.
364 In other words, \fB1i\fR has the same effect as \fB0a\fR.
368 These lines of text will
369 be added prior to line 1.
375 \fR(.,.+1)\fBjoin j T{
376 Join lines together, adjusting white space (spaces
377 and tabs) as necessary.
381 Resulting line is printed
389 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
390 Name Abbr Description Examples
393 \fRPrints lines in a more
394 unambiguous way than the \fIprint\fR
395 command does. The end of a line,
396 for example, is marked with a ``$'',
397 and tabs printed as ``^I''.
408 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
409 \fR(.,.)\fBmove \fIaddr\fB m T{
410 \fRMoves the specified lines
411 to a position after the line
412 indicated by \fIaddr\fR.
416 New current line is printed
421 \fR(.,.)\fBnumber nu T{
422 Prints each line preceded
423 by its buffer line number.
427 \0\0\fR10\0 This is line 10
433 Too involved to discuss here,
434 but if you enter open mode
436 the \s-2ESC\s0 key followed by
438 get back into normal editor
440 \fIEdit\fP is designed to
441 prevent accidental use of
446 Saves a copy of the current buffer contents as though the system had
447 just crashed. This is for use in an emergency when a
449 command has failed and you don't know how else to save your work.\(dg
458 \fR(.,.)\fBprint p Prints the text of line(s). T{
461 The second and third lines
462 after the current line
469 \(dg You should seek assistance from a system administrator as soon as
470 possible after saving a file with the
472 command, because the preserved copy of the file is saved in a
473 directory used to store temporary files, and thus, the preserved
474 copy may only be available for a short period of time.
479 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
491 \fREnds the editing session.
493 warning if you have changed the buffer
494 since last writing its contents
495 to the file. In this event you
496 must either type \fBw\fR to write,
497 or type \fBq!\fR to exit from
498 the editor without saving your changes.
502 \fRNo write since last change
508 \fR(.)\fBread \fIfile\fP r T{
510 \fRPlaces a copy of \fIfile\fR in the
511 buffer after the specified line.
512 Address 0 is permissible and causes
513 the copy of \fIfile\fR to be placed
514 at the beginning of the buffer.
515 The \fIread\fP command does not
516 erase any text already in the buffer.
517 If no line number is specified,
518 \fIfile\fR is placed after the
523 \fR"newfile" 5 lines, 86 characters
528 \fBrecover \fIfile\fP rec T{
530 Retrieves a copy of the editor buffer
531 after a system crash, editor crash,
532 phone line disconnection, or
533 \fIpreserve\fR command.
536 \fR(.,.)\fBsubstitute s T{
538 \fBsubstitute/\fIpattern\fB/\fIreplacement\fB/
539 substitute/\fIpattern\fB/\fIreplacement\fB/gc
541 \fRReplaces the first occurrence of \fIpattern\fR
543 with \fIreplacement\fP.
544 Including a \fBg\fR after the command
545 changes all occurrences of \fIpattern\fP
547 The \fBc\fR option allows the user to
548 confirm each substitution before it is
549 made; see the manual for details.
553 \fRLine 3 contains a misstake
554 :\fBs/misstake/mistake/
555 \fRLine 3 contains a mistake
563 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
564 Name Abbr Description Examples
568 \fRReverses the changes made in
569 the buffer by the last buffer-editing
571 Note that this example contains
572 a notification about the number of
578 new line number 1 is printed
580 \fR15 more lines in file ...
581 old line number 1 is printed
586 \fR(1,$)\fBwrite \fIfile\fR w T{
588 \fRCopies data from the buffer onto
589 a permanent file. If no \fIfile\fR
590 is named, the current filename
592 The file is automatically created
593 if it does not yet exist.
594 A response containing the number of
595 lines and characters in the file
596 indicates that the write
597 has been completed successfully.
598 The editor's built-in protections
599 against overwriting existing files
600 will in some circumstances
602 The form \fBw!\fR forces the
603 write, confirming that
604 an existing file is to be overwritten.
608 \fR"file7" 64 lines, 1122 characters
610 \fR"file8" File exists ...
612 \fR"file8" 64 lines, 1122 characters
616 \fR(1,$)\fBwrite! \fIfile\fP w! \^ \^
620 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
621 \fR(.)\fBz \fIcount\fP z T{
623 \fRPrints a screen full of text starting
624 with the line indicated;
625 or, if \fIcount\fR is specified,
626 prints that number of lines.
627 Variants of the \fIz\fR command
628 are described in the manual.
633 Executes the remainder of the line
634 after \fB!\fR as a \*U command.
635 The buffer is unchanged by this, and
636 control is returned to the editor when
637 the execution of \fIcommand\fR is complete.
641 \fRFri Jun 9 12:15:11 PDT 1978
649 Prints the next \fIscroll\fR of text,
650 normally half of a screen. See the
651 manual for details of the \fIscroll\fR
657 An address alone followed by a carriage
658 return causes the line to be printed.
659 A carriage return by itself prints the
660 line following the current line.
664 the line after the current line
671 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
672 \fB/\fIpattern\fB/ T{
674 \fRSearches for the next line in which
675 \fIpattern\fR occurs and prints it.
678 \fR:\fB/This pattern/
679 \fRThis pattern next occurs here.
685 Repeats the most recent search.
689 \fRThis pattern also occurs here.
694 \fB?\fIpattern\fB? T{
695 Searches in the reverse direction
700 Repeats the most recent search,
701 moving in the reverse direction