home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / share / doc / usd / 16.ex / ex.summary < prev    next >
Encoding:
Text File  |  1991-04-17  |  15.5 KB  |  735 lines

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