|
|
1.1 root 1: .\" Copyright (c) 1980 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)ex.summary 6.1 (Berkeley) 5/30/86
6: .\"
7: .ds p \v'-0.2'.\v'+0.2'
8: .ds U \s-2UNIX\s+2
9: .ds c \v'-0.2':\v'+0.2'
10: .nr PO .25i
11: .nr LL 6.75i
12: .lt 6.75i
13: .ll 6.75i
14: .ds CH
15: .ds LF Computing Services, U.C. Berkeley
16: .ds RF April 3, 1979
17: .de SP
18: .sp 1v
19: ..
20: .nr PI 3n
21: .nr PD 0
22: .ND
23: .ps 12
24: .ft B
25: .ce 1
26: Ex/Edit Command Summary (Version 2.0)
27: .ft R
28: .nr VS 11
29: .nr PS 9
30: .nr HM 0.5i
31: .nr CW
32: .2C
33: .PP
34: .I Ex
35: and
36: .I edit
37: are text editors, used for creating
38: and modifying files of text on the \*U
39: computer system.
40: .I Edit
41: is a variant of
42: .I ex
43: with features designed to
44: make it less complicated
45: to learn and use.
46: In terms of command syntax and effect
47: the editors are essentially identical,
48: and this command summary applies to both.
49: .PP
50: The summary is meant as a quick reference
51: for users already acquainted
52: with
53: .I edit
54: or \fIex\fP.
55: Fuller explanations of the editors are available
56: in the documents
57: .I
58: Edit: A Tutorial
59: .R
60: (a self-teaching introduction) and the
61: .I
62: Ex Reference Manual
63: .R
64: (the comprehensive reference source for
65: both \fIedit\fP and \fIex\fP).
66: Both of these writeups are available in the
67: Computing Services Library.
68: .PP
69: In the examples included with the
70: summary, commands and text entered by
71: the user are printed in \fBboldface\fR to
72: distinguish them from responses printed
73: by the computer.
74: .sp 0.45v
75: .LP
76: .B
77: The Editor Buffer
78: .PP
79: In order to perform its tasks
80: the editor sets aside a temporary
81: work space,
82: called a \fIbuffer\fR,
83: separate from the user's permanent
84: file.
85: Before starting to work on an existing
86: file the editor makes a copy of it in the
87: buffer, leaving the original untouched.
88: All editing changes are made to the
89: buffer copy, which must then
90: be written back to the permanent
91: file in order to update the
92: old version.
93: The buffer disappears
94: at the end of the editing session.
95: .sp 0.45v
96: .LP
97: .B
98: Editing: Command and Text Input Modes
99: .PP
100: .R
101: During an editing session there are
102: two usual modes of operation:
103: \fIcommand\fP mode and \fItext input\fP
104: mode.
105: (This disregards, for the moment,
106: .I open
107: and
108: .I visual
109: modes, discussed below.)
110: In command mode, the editor issues a
111: colon prompt (:)
112: to show that it is ready to
113: accept and execute a command.
114: In text input mode, on the other hand, there is
115: no prompt and the editor merely accepts text to
116: be added to the buffer.
117: Text input mode is initiated by the commands
118: \fIappend\fP, \fIinsert\fP, and \fIchange\fP,
119: and is terminated by typing a period as the
120: first and only character on a line.
121: .sp 0.45v
122: .LP
123: .B
124: Line Numbers and Command Syntax
125: .PP
126: .R
127: The editor keeps track of lines of text
128: in the buffer by numbering them consecutively
129: starting with 1 and renumbering
130: as lines are added or deleted.
131: At any given time the editor is positioned
132: at one of these lines; this position is
133: called the \fIcurrent line\fP.
134: Generally, commands that change the
135: contents of the buffer print the
136: new current line at the end of their
137: execution.
138: .PP
139: Most commands can be preceded by one or two
140: line-number addresses which indicate the lines
141: to be affected.
142: If one number is given the command operates on
143: that line only; if two, on an inclusive range
144: of lines.
145: Commands that can take line-number prefixes also
146: assume default prefixes if none are given.
147: The default assumed by each command is designed
148: to make it convenient to use in many instances
149: without any line-number prefix.
150: For the most part, a command used without a
151: prefix operates on the current line,
152: though exceptions to this rule should be noted.
153: The \fIprint\fP command
154: by itself, for instance, causes
155: one line, the current line, to be
156: printed at the terminal.
157: .PP
158: The summary shows the number of line addresses
159: that can be
160: prefixed to each command as well as
161: the defaults assumed if they are omitted.
162: For example,
163: .I (.,.)
164: means that up to 2 line-numbers may be given,
165: and that if none is given the
166: command operates on the current line.
167: (In the address prefix notation, ``.'' stands
168: for the current line and ``$'' stands for
169: the last line of the buffer.)
170: If no such notation appears, no
171: line-number prefix may be used.
172: .PP
173: Some commands take trailing
174: information;
175: only
176: the more important instances of this
177: are mentioned in the summary.
178: .sp 0.25v
179: .LP
180: .B
181: Open and Visual Modes
182: .PP
183: .R
184: Besides command and text input modes,
185: .I ex
186: and
187: .I edit
188: provide on some CRT terminals other modes of editing,
189: .I open
190: and
191: .I visual .
192: In these modes the cursor can
193: be moved to individual words
194: or characters in a line.
195: The commands then given are very different
196: from the standard editor commands; most do not appear on the screen when
197: typed.
198: .I
199: An Introduction to Display Editing with Vi
200: .R
201: provides a full discussion.
202: .sp 0.25v
203: .LP
204: .B
205: Special Characters
206: .PP
207: .R
208: .fi
209: Some characters take on special meanings
210: when used in context searches
211: and in patterns given to the \fIsubstitute\fP command.
212: For \fIedit\fR, these are ``^'' and ``$'',
213: meaning the beginning and end of a line,
214: respectively.
215: .I Ex
216: has the following additional special characters:
217: .B
218: .ce 1
219: \&. & * [ ] ~
220: .R
221: To use one of the special characters as its
222: simple graphic representation
223: rather than with its special meaning,
224: precede it by a backslash (\\).
225: The backslash always has a special meaning.
226: .1C
227: .rm LF
228: .rm RF
229: .rm CF
230: .nr FM 0.4
231: .TS
232: cp10 cp10 cp10 cp10
233: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
234: Name Abbr Description Examples
235: .sp 1.75
236: (.)\fBappend a T{
237: Begins text input mode,
238: adding lines to the buffer after
239: the line specified. Appending continues
240: until ``.'' is typed alone at the
241: beginning of a new line, followed by
242: a carriage return. \fI0a\fR places
243: lines at the beginning of the buffer.
244: T} T{
245: .nf
246: \fR:\fBa
247: Three lines of text
248: are added to the buffer
249: after the current line.
250: \*p
251: .R
252: \*c
253: .fi
254: T}
255: .SP
256: \fR(.,.)\fBchange c T{
257: Deletes indicated line(s) and
258: initiates text input mode to
259: replace them with new text which follows.
260: New text is terminated the same way
261: as with \fIappend\fR.
262: T} T{
263: .nf
264: :\fB5,6c
265: Lines 5 and 6 are
266: deleted and replaced by
267: these three lines.
268: \*p
269: .R
270: \*c
271: .fi
272: T}
273: .SP
274: \fR(.,.)\fBcopy \fIaddr co T{
275: Places a copy of the specified lines
276: after the line indicated by \fIaddr\fR.
277: The example places a copy of lines 8 through
278: 12, inclusive, after line 25.
279: T} T{
280: .nf
281: \fR:\fB8,12co 25
282: \fRLast line copied is printed
283: \fR\*c
284: .fi
285: T}
286: .SP
287: \fR(.,.)\fBdelete d T{
288: Removes lines from the buffer
289: and prints the current line after the deletion.
290: T} T{
291: .nf
292: \fR:\fB13,15d
293: \fRNew current line is printed
294: \*c
295: .fi
296: T}
297: .TE
298: .sp 0.5v
299: .TS
300: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
301: T{
302: \fBedit \fIfile\fP
303: .br
304: \fBedit! \fIfile\fP
305: T} T{
306: e
307: .br
308: e!
309: T} T{
310: .fi
311: \fRClears the editor buffer and then
312: copies into it the named \fIfile\fR,
313: which becomes the current file.
314: This is a way of shifting to a different
315: file
316: without leaving the editor.
317: The editor issues a warning
318: message if this command is used before
319: saving changes
320: made to the file already in the buffer;
321: using the form \fBe!\fR overrides this protective mechanism.
322: T} T{
323: .nf
324: \fR:\fBe ch10\fR
325: No write since last change
326: :\fBe! ch10\fR
327: "ch10" 3 lines, 62 characters
328: \*c
329: .fi
330: T}
331: .SP
332: \fBfile \fIname\fR f T{
333: \fRIf followed by a \fIname\fR, renames
334: the current file to \fIname\fR.
335: If used without \fIname\fR, prints
336: the name of the current file.
337: T} T{
338: .nf
339: \fR:\fBf ch9
340: \fR"ch9" [Modified] 3 lines ...
341: :\fBf
342: \fR"ch9" [Modified] 3 lines ...
343: \*c
344: .fi
345: T}
346: .SP
347: (1,$)\fBglobal g \fBglobal/\fIpattern\fB/\fIcommands T{
348: .nf
349: :\fBg/nonsense/d
350: \fR\*c
351: .fi
352: T}
353: \fR(1,$)\fBglobal! g!\fR or \fBv T{
354: Searches the entire buffer (unless a smaller
355: range is specified by line-number prefixes) and
356: executes \fIcommands\fR on every line with
357: an expression matching \fIpattern\fR.
358: The second form, abbreviated
359: either \fBg!\fR or \fBv\fR,
360: executes \fIcommands\fR on lines that \fIdo
361: not\fR contain the expression \fIpattern\fR.
362: T} \^
363: .SP
364: \fR(.)\fBinsert i T{
365: Inserts new lines of text immediately before the specified line.
366: Differs from
367: .I append
368: only in that text is placed before, rather than after, the indicated line.
369: In other words, \fB1i\fR has the same effect as \fB0a\fR.
370: T} T{
371: .nf
372: :\fB1i
373: These lines of text will
374: be added prior to line 1.
375: \&.
376: \fR:
377: .fi
378: T} \^
379: .SP
380: \fR(.,.+1)\fBjoin j T{
381: Join lines together, adjusting white space (spaces
382: and tabs) as necessary.
383: T} T{
384: .nf
385: :\fB2,5j\fR
386: Resulting line is printed
387: :
388: .fi
389: T} \^
390: .TE
391: .bp
392: .TS
393: cp10 cp10 cp10 cp10
394: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
395: Name Abbr Description Examples
396: .sp 1.75
397: \fR(.,.)\fBlist l T{
398: \fRPrints lines in a more
399: unambiguous way than the \fIprint\fR
400: command does. The end of a line,
401: for example, is marked with a ``$'',
402: and tabs printed as ``^I''.
403: T} T{
404: .nf
405: :\fB9l
406: \fRThis is line 9$
407: \*c
408: .fi
409: T}
410: .TE
411: .sp 0.5v
412: .TS
413: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
414: \fR(.,.)\fBmove \fIaddr\fB m T{
415: \fRMoves the specified lines
416: to a position after the line
417: indicated by \fIaddr\fR.
418: T} T{
419: .nf
420: \fR:\fB12,15m 25\fR
421: New current line is printed
422: \*c
423: .fi
424: T}
425: .SP
426: \fR(.,.)\fBnumber nu T{
427: Prints each line preceded
428: by its buffer line number.
429: T} T{
430: .nf
431: \fR:\fBnu
432: \0\0\fR10\0 This is line 10
433: \*c
434: .fi
435: T}
436: .SP
437: \fR(.)\fBopen o T{
438: Too involved to discuss here,
439: but if you enter open mode
440: accidentally, press
441: the \s-2ESC\s0 key followed by
442: \fBq\fR to
443: get back into normal editor
444: command mode.
445: \fIEdit\fP is designed to
446: prevent accidental use of
447: the open command.
448: T}
449: .SP
450: \fBpreserve pre T{
451: Saves a copy of the current buffer contents as though the system had
452: just crashed. This is for use in an emergency when a
453: .I write
454: command has failed and you don't know how else to save your work.\(dg
455: T} T{
456: .nf
457: :\fBpreserve\fR
458: File preserved.
459: :
460: .fi
461: T}
462: .SP
463: \fR(.,.)\fBprint p Prints the text of line(s). T{
464: .nf
465: :\fB+2,+3p\fR
466: The second and third lines
467: after the current line
468: :
469: .fi
470: T}
471: .TE
472: .FS
473: \(dg Seek assistance from a consultant as soon as possible
474: after saving a file with the
475: .I preserve
476: command, because the file is saved on system storage space for only one week.
477: .FE
478: .SP
479: .nf
480: .TS
481: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
482: T{
483: .nf
484: \fBquit
485: quit!
486: .fi
487: T} T{
488: .nf
489: q
490: q!
491: T} T{
492: .fi
493: \fREnds the editing session.
494: You will receive a
495: warning if you have changed the buffer
496: since last writing its contents
497: to the file. In this event you
498: must either type \fBw\fR to write,
499: or type \fBq!\fR to exit from
500: the editor without saving your changes.
501: T} T{
502: .nf
503: \fR:\fBq
504: \fRNo write since last change
505: :\fBq!
506: \fR%
507: .fi
508: T}
509: .SP
510: \fR(.)\fBread \fIfile\fP r T{
511: .fi
512: \fRPlaces a copy of \fIfile\fR in the
513: buffer after the specified line.
514: Address 0 is permissible and causes
515: the copy of \fIfile\fR to be placed
516: at the beginning of the buffer.
517: The \fIread\fP command does not
518: erase any text already in the buffer.
519: If no line number is specified,
520: \fIfile\fR is placed after the
521: current line.
522: T} T{
523: .nf
524: \fR:\fB0r newfile
525: \fR"newfile" 5 lines, 86 characters
526: \*c
527: .fi
528: T}
529: .SP
530: \fBrecover \fIfile\fP rec T{
531: .fi
532: Retrieves a copy of the editor buffer
533: after a system crash, editor crash,
534: phone line disconnection, or
535: \fIpreserve\fR command.
536: T}
537: .SP
538: \fR(.,.)\fBsubstitute s T{
539: .nf
540: \fBsubstitute/\fIpattern\fB/\fIreplacement\fB/
541: substitute/\fIpattern\fB/\fIreplacement\fB/gc
542: .fi
543: \fRReplaces the first occurrence of \fIpattern\fR
544: on a line
545: with \fIreplacement\fP.
546: Including a \fBg\fR after the command
547: changes all occurrences of \fIpattern\fP
548: on the line.
549: The \fBc\fR option allows the user to
550: confirm each substitution before it is
551: made; see the manual for details.
552: T} T{
553: .nf
554: :\fB3p
555: \fRLine 3 contains a misstake
556: :\fBs/misstake/mistake/
557: \fRLine 3 contains a mistake
558: \*c
559: .fi
560: T}
561: .TE
562: .bp
563: .TS
564: cp10 cp10 cp10 cp10
565: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
566: Name Abbr Description Examples
567: .sp 1.75
568: \fBundo u T{
569: .fi
570: \fRReverses the changes made in
571: the buffer by the last buffer-editing
572: command.
573: Note that this example contains
574: a notification about the number of
575: lines affected.
576: T} T{
577: .nf
578: \fR:\fB1,15d
579: \fR15 lines deleted
580: new line number 1 is printed
581: :\fBu
582: \fR15 more lines in file ...
583: old line number 1 is printed
584: \*c
585: .fi
586: T}
587: .SP
588: \fR(1,$)\fBwrite \fIfile\fR w T{
589: .fi
590: \fRCopies data from the buffer onto
591: a permanent file. If no \fIfile\fR
592: is named, the current filename
593: is used.
594: The file is automatically created
595: if it does not yet exist.
596: A response containing the number of
597: lines and characters in the file
598: indicates that the write
599: has been completed successfully.
600: The editor's built-in protections
601: against overwriting existing files
602: will in some circumstances
603: inhibit a write.
604: The form \fBw!\fR forces the
605: write, confirming that
606: an existing file is to be overwritten.
607: T} T{
608: .nf
609: \fR:\fBw
610: \fR"file7" 64 lines, 1122 characters
611: :\fBw file8
612: \fR"file8" File exists ...
613: :\fBw! file8
614: \fR"file8" 64 lines, 1122 characters
615: \*c
616: .fi
617: T}
618: \fR(1,$)\fBwrite! \fIfile\fP w! \^ \^
619: .TE
620: .sp 0.5v
621: .TS
622: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
623: \fR(.)\fBz \fIcount\fP z T{
624: .fi
625: \fRPrints a screen full of text starting
626: with the line indicated;
627: or, if \fIcount\fR is specified,
628: prints that number of lines.
629: Variants of the \fIz\fR command
630: are described in the manual.
631: T}
632: .SP
633: \fB!\fIcommand T{
634: .fi
635: Executes the remainder of the line
636: after \fB!\fR as a \*U command.
637: The buffer is unchanged by this, and
638: control is returned to the editor when
639: the execution of \fIcommand\fR is complete.
640: T} T{
641: .nf
642: \fR:\fB!date
643: \fRFri Jun 9 12:15:11 PDT 1978
644: !
645: \*c
646: .fi
647: T}
648: .SP
649: \fRcontrol-d T{
650: .fi
651: Prints the next \fIscroll\fR of text,
652: normally half of a screen. See the
653: manual for details of the \fIscroll\fR
654: option.
655: T}
656: .SP
657: \fR(.+1)<cr> T{
658: .fi
659: An address alone followed by a carriage
660: return causes the line to be printed.
661: A carriage return by itself prints the
662: line following the current line.
663: T} T{
664: .nf
665: :\fR<cr>
666: the line after the current line
667: \*c
668: .fi
669: T}
670: .TE
671: .sp 0.5v
672: .TS
673: ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
674: \fB/\fIpattern\fB/ T{
675: .fi
676: \fRSearches for the next line in which
677: \fIpattern\fR occurs and prints it.
678: T} T{
679: .nf
680: \fR:\fB/This pattern/
681: \fRThis pattern next occurs here.
682: \*c
683: .fi
684: T}
685: .SP
686: \fB// T{
687: Repeats the most recent search.
688: T} T{
689: .nf
690: \fR:\fB//
691: \fRThis pattern also occurs here.
692: \*c
693: .fi
694: T}
695: .SP
696: \fB?\fIpattern\fB? T{
697: Searches in the reverse direction
698: for \fIpattern\fP.
699: T}
700: .SP
701: \fB?? T{
702: Repeats the most recent search,
703: moving in the reverse direction
704: through the buffer.
705: T}
706: .TE
707:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.