home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / EDITOR / NVI179B / NVI179B.ZIP / docs / USD.doc / exref / ex.summary < prev    next >
Text File  |  1996-08-18  |  16KB  |  731 lines

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