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