diff options
author | Jason McIntyre <jmc@cvs.openbsd.org> | 2004-01-24 12:29:14 +0000 |
---|---|---|
committer | Jason McIntyre <jmc@cvs.openbsd.org> | 2004-01-24 12:29:14 +0000 |
commit | 506d47fae8db1007bf9ff36c4f15eacc9efe3691 (patch) | |
tree | 296e6205d94ad122ab6fe6eb722e8ce60419d318 /usr.bin/vi/docs | |
parent | 1794bc157328c89165566d6796bae94bc89662fe (diff) |
install vi tutorial docs; these have been updated to reflect reality;
help and ok millert@
Diffstat (limited to 'usr.bin/vi/docs')
-rw-r--r-- | usr.bin/vi/docs/USD.doc/vitut/Makefile | 13 | ||||
-rw-r--r-- | usr.bin/vi/docs/USD.doc/vitut/vi.apwh.ms | 124 | ||||
-rw-r--r-- | usr.bin/vi/docs/USD.doc/vitut/vi.chars | 74 | ||||
-rw-r--r-- | usr.bin/vi/docs/USD.doc/vitut/vi.in | 499 | ||||
-rw-r--r-- | usr.bin/vi/docs/USD.doc/vitut/vi.summary | 28 |
5 files changed, 381 insertions, 357 deletions
diff --git a/usr.bin/vi/docs/USD.doc/vitut/Makefile b/usr.bin/vi/docs/USD.doc/vitut/Makefile index 997885c12f8..2fc57afc4d0 100644 --- a/usr.bin/vi/docs/USD.doc/vitut/Makefile +++ b/usr.bin/vi/docs/USD.doc/vitut/Makefile @@ -1,18 +1,25 @@ -# $OpenBSD: Makefile,v 1.3 2001/01/29 01:58:36 niklas Exp $ +# $OpenBSD: Makefile,v 1.4 2004/01/24 12:29:13 jmc Exp $ DIR= usd/12.vi SRCS= vi.in vi.chars +EXTRA= vi.apwh.ms vi.summary MACROS= -ms -CLEANFILES+=summary.* viapwh.* +CLEANFILES+=summary.* viapwh.* vitut.txt paper.ps: ${SRCS} summary.ps viapwh.ps ${TBL} ${SRCS} | ${ROFF} > ${.TARGET} +vitut.txt: ${SRCS} summary.txt viapwh.txt + ${TBL} ${SRCS} | groff ${MACROS} -Tascii > ${.TARGET} summary.ps: vi.summary - ${TBL} vi.summary | ${ROFF} > ${.TARGET} + ${TBL} vi.summary | ${ROFF} > ${.TARGET} +summary.txt: vi.summary + ${TBL} vi.summary | groff ${MACROS} -Tascii > ${.TARGET} viapwh.ps: vi.apwh.ms ${ROFF} vi.apwh.ms > ${.TARGET} +viapwh.txt: vi.apwh.ms + groff ${MACROS} -Tascii vi.apwh.ms > ${.TARGET} .include <bsd.doc.mk> diff --git a/usr.bin/vi/docs/USD.doc/vitut/vi.apwh.ms b/usr.bin/vi/docs/USD.doc/vitut/vi.apwh.ms index e3a276d0fd6..3e89d573012 100644 --- a/usr.bin/vi/docs/USD.doc/vitut/vi.apwh.ms +++ b/usr.bin/vi/docs/USD.doc/vitut/vi.apwh.ms @@ -1,4 +1,4 @@ -.\" $OpenBSD: vi.apwh.ms,v 1.4 2003/06/03 02:56:22 millert Exp $ +.\" $OpenBSD: vi.apwh.ms,v 1.5 2004/01/24 12:29:13 jmc Exp $ .\" .\" Copyright (c) 1980, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,6 +29,10 @@ .\" .\" @(#)vi.apwh.ms 8.2 (Berkeley) 8/18/96 .\" +.if n \{\ +.po 5n +.ll 70n +.\} .nr LL 6.5i .nr FL 6.5i .TL @@ -37,7 +41,7 @@ Vi Command & Function Reference Alan P.W. Hewett .sp Revised for version 2.12 by Mark Horton -.CB +.\" .CB .NH 1 Author's Disclaimer .LP @@ -83,7 +87,7 @@ be denoted using the \fIupper case\fR character, but example, \fB<^D>\fR is equal to \fB<^d>\fR. The most common character abbreviations used in this list are as follows: -.VL 8 +.RS .IP <esc> 8 escape, octal 033 .IP <cr> 8 @@ -104,7 +108,7 @@ formfeed, ^L, octal 014 space, octal 040 .IP <del> 8 delete, octal 0177 -.LE +.RE .sp 1 .NH 1 Basics @@ -122,8 +126,7 @@ Bourne Shell .LP To manually set your terminal type to 2621 you would type: .DS -TERM=2621 -export TERM +export TERM=2621 .DE .PP There are various ways of having this automatically or @@ -216,7 +219,7 @@ be necessary to type <esc> first. .NH 2 Cursor and Page Motion .LP -.VL 16 +.RS .B NOTE: The arrow keys (see the next four commands) on certain kinds of terminals will not work with the @@ -227,23 +230,23 @@ the arrow keys, since they do not require memorization of which hjkl key is which. The mnemonic value of hjkl is clear from looking at the keyboard of an adm3a. .sp -.IP "[cnt]<bs> or [cnt]h or [cnt]\(<-" 16 +.IP "[cnt]h or [cnt]^H" 16 .br Move the cursor to the left one character. Cursor stops at the left margin of the page. If cnt is given, these commands move that many spaces. -.IP "[cnt]^N or [cnt]j or [cnt]\(da or [cnt]<lf>" 16 +.IP "[cnt]^N or [cnt]j or [cnt]^J" 16 .br Move down one line. Moving off the screen scrolls the window to force a new line onto the screen. Mnemonic: \fBN\fRext -.IP "[cnt]^P or [cnt]k or [cnt]\(ua" 16 +.IP "[cnt]^P or [cnt]k" 16 .br Move up one line. Moving off the top of the screen forces new text onto the screen. Mnemonic: \fBP\fRrevious -.IP "[cnt]<sp> or [cnt]l or [cnt]\(->" 16 +.IP "[cnt]<sp> or [cnt]l" 16 .br Move to the right one character. Cursor will not go beyond the end of the line. @@ -272,18 +275,18 @@ position the cursor at the beginning of the word. Mnemonic: next-\fBw\fRord .IP "[cnt]W" 16 Move the cursor to the beginning of the next word which follows -a "white space" (<sp>,<tab>, or <nl>). Ignore other punctuation. +a "whitespace" (<sp>,<tab>, or <nl>). Ignore other punctuation. .IP "[cnt]b" 16 Move the cursor to the preceding word. Mnemonic: \fBb\fRackup-word .IP "[cnt]B" 16 Move the cursor to the preceding word that is separated from the -current word by a "white space" (<sp>,<tab>, or <nl>). +current word by a "whitespace" (<sp>,<tab>, or <nl>). .IP "[cnt]e" 16 Move the cursor to the end of the current word or the end of the "cnt"'th word hence. Mnemonic: \fBe\fRnd-of-word .IP "[cnt]E" 16 Move the cursor to the end of the current word which is delimited by -"white space" (<sp>,<tab>, or <nl>). +"whitespace" (<sp>,<tab>, or <nl>). .IP "[line number]G" 16 .br Move the cursor to the line specified. Of particular use are the @@ -378,12 +381,12 @@ cursor or scrolling the screen. .IP "\(ga\(ga" 16 Move the cursor back to the exact spot on the line where it was located before the last "non-relative" move. -.LE +.RE .NH 2 Searches .LP The following commands allow you to search for items in a file. -.VL 16 +.RS .IP [cnt]f{chr} 16 .sp 1 Search forward on the line for the next or "cnt"'th occurrence of @@ -431,7 +434,7 @@ direction. .sp 1 Using the \fB:\fR syntax it is possible to do global searches ala the standard UNIX "ed" editor. -.LE +.RE .NH 2 Text Insertion .LP @@ -440,7 +443,7 @@ text insertions are terminated with an <esc> character. The last change can always be \fBundone\fR by typing a \fBu\fR. The text insert in insertion mode can contain newlines. -.VL 16 +.RS .IP a{text}<esc> 16 Insert text immediately following the cursor position. Mnemonic: \fBa\fRppend @@ -458,13 +461,13 @@ insert text there. Mnemonic: \fBo\fRpen new line .IP O{text}<esc> 16 Insert a new line preceding the line on which the cursor appears and insert text there. -.LE +.RE .NH 2 Text Deletion .LP The following commands allow the user to delete text in various ways. All changes can always be \fBundone\fR by typing the \fBu\fR command. -.VL 16 +.RS .IP "[cnt]x" 16 Delete the character or characters starting at the cursor position. .IP "[cnt]X" 16 @@ -478,14 +481,14 @@ Mnemonic: \fBD\fRelete the rest of line Deletes one or more occurrences of the specified motion. Any motion from sections 4.1 and 4.2 can be used here. The d can be stuttered (e.g. [cnt]dd) to delete cnt lines. -.LE +.RE .NH 2 Text Replacement .LP The following commands allow the user to simultaneously delete and insert new text. All such actions can be \fBundone\fR by typing \fBu\fR following the command. -.VL 16 +.RS .IP "r<chr>" 16 Replaces the character at the current cursor position with <chr>. This is a one character replacement. No <esc> is required for termination. @@ -510,7 +513,7 @@ insertion text. A "$" will appear at the end of the last item that is being deleted unless the deletion involves whole lines. Motion's can be any motion from sections 4.1 or 4.2. Stuttering the c (e.g. [cnt]cc) changes cnt lines. -.LE +.RE .NH 2 Moving Text .LP @@ -534,7 +537,7 @@ in such a buffer is appended to it instead of replacing it. .FE There are two more basic commands and some variations useful in getting and putting text into a file. -.VL 16 +.RS .IP ["<a-z>][cnt]y{motion} 16 .sp 1 Yank the specified item or "cnt" items and put in the "undo" buffer or @@ -580,17 +583,20 @@ The text is shifted by one \fBshiftwidth\fR. (See section 6.) \fB<<\fR means left shift the current line or lines. Once the line has reached the left margin it is not further affected. .IP [cnt]={motion} 16 -Prettyprints the indicated area according to -.B lisp -conventions. -The area should be a lisp s-expression. -.LE +.\" Prettyprints the indicated area according to +.\" .B lisp +.\" conventions. +.\" The area should be a lisp s-expression. +Displays the line number. +If no prefix is specified,the line number of the last line in the file +is displayed. +.RE .NH 2 Miscellaneous Commands .LP \fBVi\fR has a number of miscellaneous commands that are very useful. They are: -.VL 16 +.RS .IP ZZ 16 This is the normal way to exit from vi. If any changes have been made, the file is written out. @@ -630,10 +636,10 @@ Switch to \fBex\fR editing mode. In this mode \fBvi\fR will behave very much like \fBed\fR. The editor in this mode will operate on single lines normally and will not attempt to keep the "window" up to date. -Once in this mode it is also possible to switch to the \fBopen\fR -mode of editing. By entering the command \fB[line number]open<nl>\fR -you enter this mode. It is similar to the normal visual mode -except the window is only \fBone\fR line long. +.\" Once in this mode it is also possible to switch to the \fBopen\fR +.\" mode of editing. By entering the command \fB[line number]open<nl>\fR +.\" you enter this mode. It is similar to the normal visual mode +.\" except the window is only \fBone\fR line long. Mnemonic: \fBQ\fRuit visual mode .IP ^] 16 An abbreviation for a tag command. @@ -646,7 +652,7 @@ Any UNIX filter (e.g. command that reads the standard input and outputs something to the standard output) can be sent a section of the current file and have the output of the command replace the original text. Useful -examples are programs like \fBcb\fR, \fBsort\fR, and +examples are programs like \fBsort\fR and \fBnroff\fR. For instance, using \fBsort\fR it would be possible to sort a section of the current file into a new list. Using \fB!!\fR means take a line or lines starting at the line the @@ -656,13 +662,13 @@ To just escape to the shell for one command, use :!{cmd}<nl>, see section 5. .IP z{cnt}<nl> 16 This resets the current window size to "cnt" lines and redraws the screen. -.LE +.RE .NH 2 Special Insert Characters .LP There are some characters that have special meanings during insert modes. They are: -.VL 16 +.RS .IP ^V 16 During inserts, typing a ^V allows you to quote control characters into the file. Any character typed after the ^V will be inserted @@ -686,7 +692,7 @@ Mnemonic: erase \fBW\fRord The backspace always serves as an erase during insert modes in addition to your normal "erase" character. To insert a <bs> into your file, use the <^V> to quote it. -.LE +.RE .NH 1 \fB:\fR Commands .LP @@ -696,7 +702,7 @@ the bottom on the screen in preparation for a command. In the also from this mode that you exit from \fBvi\fR or switch to different files. All commands of this variety are terminated by a <nl>, <cr>, or <esc>. -.VL 16 +.RS .IP ":w[!] [file]" 16 Causes \fBvi\fR to write out the current text to the disk. It is written to the file you are editing unless "file" is supplied. If @@ -767,7 +773,7 @@ programs so that by saying \fB:ta function<nl>\fR you will be switched to that function. It could also be useful when editing multi-file documents, though the \fBtags\fR file would have to be generated manually. -.LE +.RE .NH 1 Special Arrangements for Startup .PP @@ -865,7 +871,7 @@ These are usually placed in your .profile or .login. If you are running a system without environments (such as version 6) you can place the set command in the file .exrc in your home directory. -.VL 16 +.RS .IP autoindent\ ai 16 Default: noai Type: toggle .br @@ -898,7 +904,7 @@ Default: noeb Type: toggle .br Error messages are preceded by a <bell>. .IP hardtabs\ ht 16 -Default: hardtabs=8 Type: numeric +Default: hardtabs=0 Type: numeric .br This option contains the value of hardware tabs in your terminal, or of software tabs expanded by the Unix system. @@ -907,11 +913,11 @@ Default: noic Type: toggle .br All upper case characters are mapped to lower case in regular expression matching. -.IP lisp 16 -Default: nolisp Type: toggle -.br -Autoindent for \fBlisp\fR code. The commands \fB( ) [[\fR and \fB]]\fR -are modified appropriately to affect s-expressions and functions. +.\" .IP lisp 16 +.\" Default: nolisp Type: toggle +.\" .br +.\" Autoindent for \fBlisp\fR code. The commands \fB( ) [[\fR and \fB]]\fR +.\" are modified appropriately to affect s-expressions and functions. .IP list 16 Default: nolist Type: toggle .br @@ -938,7 +944,7 @@ option prevents automatic <cr>s from taking place, and speeds up output of indented lines, at the expense of losing typeahead on some versions of UNIX. .IP paragraphs\ para 16 -Default: para=IPLPPPQPP\ bp Type: string +Default: para=IPLPPPQPP LIpplpipbp Type: string .br Each pair of characters in the string indicate \fBnroff\fR macros which are to be treated as the beginning of a paragraph for the @@ -977,7 +983,7 @@ Default: scroll={1/2 window} Type: numeric This is the number of lines that the screen scrolls up or down when using the <^U> and <^D> commands. .IP sections 16 -Default: sections=SHNHH HU Type: string +Default: sections=NHSHH HUnhsh Type: string .br Each two character pair of this string specify \fBnroff\fR macro names which are to be treated as the beginning of a section by the @@ -1000,11 +1006,11 @@ Default: nosm Type: toggle .br When a \fB)\fR or \fB}\fR is typed, show the matching \fB(\fR or \fB{\fR by moving the cursor to it for one second if it is on the current screen. -.IP slowopen\ slow 16 -Default: terminal dependent Type: toggle -.br -On terminals that are slow and unintelligent, this option prevents the -updating of the screen some of the time to improve speed. +.\" .IP slowopen\ slow 16 +.\" Default: terminal dependent Type: toggle +.\" .br +.\" On terminals that are slow and unintelligent, this option prevents the +.\" updating of the screen some of the time to improve speed. .IP tabstop\ ts 16 Default: ts=8 Type: numeric .br @@ -1023,10 +1029,10 @@ set term command, and do ``vi.'' to get back into visual. Or exit vi, fix $TERM, and reenter. The definitions that drive a particular terminal type are found in the file \fB/etc/termcap\fR. -.IP terse 16 -Default: terse Type: toggle -.br -When set, the error diagnostics are short. +.\" .IP terse 16 +.\" Default: terse Type: toggle +.\" .br +.\" When set, the error diagnostics are short. .IP warn 16 Default: warn Type: toggle .br @@ -1076,4 +1082,4 @@ Default: nowa Type: toggle \fBVi\fR normally makes a number of checks before it writes out a file. This prevents the user from inadvertently destroying a file. When the "writeany" option is enabled, \fBvi\fR no longer makes these checks. -.LE +.RE diff --git a/usr.bin/vi/docs/USD.doc/vitut/vi.chars b/usr.bin/vi/docs/USD.doc/vitut/vi.chars index ef3ff396e08..61092df7abc 100644 --- a/usr.bin/vi/docs/USD.doc/vitut/vi.chars +++ b/usr.bin/vi/docs/USD.doc/vitut/vi.chars @@ -1,4 +1,4 @@ -.\" $OpenBSD: vi.chars,v 1.4 2003/06/03 02:56:22 millert Exp $ +.\" $OpenBSD: vi.chars,v 1.5 2004/01/24 12:29:13 jmc Exp $ .\" .\" Copyright (c) 1980, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)vi.chars 8.3 (Berkeley) 6/27/96 .\" -.bd S 3 +.\" .bd S 3 .pn 21 .de iP .IP "\fB\\$1\fR" \\$2 @@ -57,7 +57,7 @@ is not available. A \fB^@\fR cannot be part of the file due to the editor implementation (7.5f). .iP "^A" 15 -Unused. +Search forward for the current word. .iP "^B" 15 Backward window. A count specifies repetition. @@ -65,11 +65,11 @@ Two lines of continuity are kept if possible (2.1, 6.1, 7.2). .iP "^C" 15 Unused. .iP "^D" 15 -As a command, scrolls down a half-window of text. +As a command, scrolls down a half-window of text. A count gives the number of (logical) lines to scroll, and is remembered for future \fB^D\fR and \fB^U\fR commands (2.1, 7.2). -During an insert, backtabs over \fIautoindent\fR white space at the beginning -of a line (6.6, 7.5); this white space cannot be backspaced over. +During an insert, backtabs over \fIautoindent\fR whitespace at the beginning +of a line (6.6, 7.5); this whitespace cannot be backspaced over. .iP "^E" 15 Exposes one more line below the current screen in the file, leaving the cursor where it is if possible. @@ -138,18 +138,19 @@ except that some teletype drivers will eat the so that the editor never sees it. .iP "^R" 15 Redraws the current screen, eliminating logical lines not corresponding -to physical lines (lines with only a single @ character on them). -On hardcopy terminals in \fIopen\fR mode, retypes the current line +to physical lines (lines with only a single @ character on them) +.\" On hardcopy terminals in \fIopen\fR mode, retypes the current line (5.4, 7.2, 7.8). .iP "^S" 15 Unused. Some teletype drivers use .B ^S to suspend output until -.B ^Q is pressed. +.B ^Q +is pressed. .iP "^T" 15 Not a command character. During an insert, with \fIautoindent\fR set and at the beginning of the -line, inserts \fIshiftwidth\fR white space. +line, inserts \fIshiftwidth\fR whitespace. .iP "^U" 15 Scrolls the screen up, inverting \fB^D\fR which scrolls down. Counts work as they do for \fB^D\fR, and the previous scroll amount is common to both. @@ -192,12 +193,12 @@ Unused. Searches for the word which is after the cursor as a tag. Equivalent to typing \fB:ta\fR, this word, and then a \s-2CR\s0. Mnemonically, this command is ``go right to'' (7.3). -.iP "^\(ua" 15 +.iP "^^" 15 Equivalent to \fB:e #\fR\s-2CR\s0, returning to the previous position in the last edited file, or editing a file which you specified if you got a `No write since last change diagnostic' and do not want to have to type the file name again (7.3). -(You have to do a \fB:w\fR before \fB^\(ua\fR +(You have to do a \fB:w\fR before \fB^^\fR will work in this case. If you do not wish to write the file you should do \fB:e!\ #\fR\s-2CR\s0 instead.) .iP "^_" 15 @@ -239,7 +240,7 @@ place text (4.3, 6.3) .iP "#" 15 The macro character which, when followed by a number, will substitute for a function key on terminals without function keys (6.9). -In input mode, +In input mode, if this is your erase character, it will delete the last character you typed in input mode, and must be preceded with a \fB\e\fR to insert it, since it normally backs over the last input character you gave. @@ -269,9 +270,9 @@ over complete lines; if you use \fB\(ga\fR, the operation takes place from the exact marked place to the current cursor position within the line. .iP "(" 15 -Retreats to the beginning of a -sentence, or to the beginning of a \s-2LISP\s0 s-expression -if the \fIlisp\fR option is set. +Retreats to the beginning of a sentence. +.\" or to the beginning of a \s-2LISP\s0 s-expression +.\" if the \fIlisp\fR option is set. A sentence ends at a \fB. !\fR or \fB?\fR which is followed by either the end of a line or by two spaces. Any number of closing \fB) ] "\fR and \fB\(aa\fR characters may appear after the \fB. !\fR or \fB?\fR, @@ -307,8 +308,8 @@ a \fB2dw\fR, \fB3.\fR deletes three words (3.3, 6.3, 7.2, 7.4). .iP "/" 15 Reads a string from the last line on the screen, and scans forward for the next occurrence of this string. The normal input editing sequences may -be used during the input on the bottom line; an returns to command state -without ever searching. +be used during the input on the bottom line. +.\" an returns to command state without ever searching. The search begins when you hit \s-2CR\s0 to terminate the pattern; the cursor moves to the beginning of the last line to indicate that the search is in progress; the search may then @@ -326,7 +327,7 @@ a closing \fB/\fR and then an offset \fB+\fR\fIn\fR or \fB\-\fR\fIn\fR. .IP To include the character \fB/\fR in the search string, you must escape it with a preceding \fB\e\fR. -A \fB\(ua\fR at the beginning of the pattern forces the match to occur +A \fB^\fR at the beginning of the pattern forces the match to occur at the beginning of a line only; this speeds the search. A \fB$\fR at the end of the pattern forces the match to occur at the end of a line only. @@ -355,8 +356,11 @@ spaces. Like all operators, affects lines when repeated, as in \fB<<\fR. Counts are passed through to the basic object, thus \fB3<<\fR shifts three lines (6.6, 7.2). .iP "=" 15 -Reindents line for \s-2LISP\s0, as though they were typed in with \fIlisp\fR -and \fIautoindent\fR set (6.8). +.\" Reindents line for \s-2LISP\s0, as though they were typed in with \fIlisp\fR +.\" and \fIautoindent\fR set (6.8). +Display the line number. +If a numerical prefix is specified, display its line number; +otherwise display the line number of the last line in the file. .iP ">" 15 An operator which shifts lines right one \fIshiftwidth\fR, normally 8 spaces. Affects lines when repeated as in \fB>>\fR. Counts repeat the @@ -396,9 +400,9 @@ In any case the cursor is moved to the first non-white character on the line. If used as the target of an operator, full lines are affected (2.3, 3.2). .iP "I" 15 -Inserts at the beginning of a line; a synonym for \fB\(uai\fR. +Inserts at the beginning of a line; a synonym for \fB^i\fR. .iP "J" 15 -Joins together lines, supplying appropriate white space: one space between +Joins together lines, supplying appropriate whitespace: one space between words, two spaces after a \fB.\fR, and no spaces at all if the first character of the joined on line is \fB)\fR. A count causes that many lines to be joined rather than the default two (6.5, 7.1f). @@ -419,8 +423,8 @@ of \fBn\fR. .iP "O" 15 Opens a new line above the current line and inputs text there up to an \s-2ESC\s0. A count can be used on dumb terminals to specify a number -of lines to be opened; this is generally obsolete, as the \fIslowopen\fR -option works better (3.1). +of lines to be opened. +.\" this is generally obsolete, as the \fIslowopen\fR option works better (3.1). .iP "P" 15 Puts the last deleted text back before/above the cursor. The text goes back as whole lines above the cursor if it was deleted as whole lines. @@ -459,7 +463,7 @@ Deletes the character before the cursor. A count repeats the effect, but only characters on the current line are deleted. .iP "Y" 15 Yanks a copy of the current line into the unnamed buffer, to be put back -by a later \fBp\fR or \fBP\fR; a very useful synonym for \fByy\fR. +by a later \fBp\fR or \fBP\fR; a very useful synonym for \fByy\fR. A count yanks that many lines. May be preceded by a buffer name to put lines in that buffer (7.4). .iP "ZZ" 15 @@ -473,20 +477,22 @@ macro in the \fIsections\fR option, normally a `.NH' or `.SH' and also at lines which which start with a formfeed \fB^L\fR. Lines beginning with \fB{\fR also stop \fB[[\fR; this makes it useful for looking backwards, a function at a time, in C -programs. If the option \fIlisp\fR is set, stops at each \fB(\fR at the -beginning of a line, and is thus useful for moving backwards at the top -level \s-2LISP\s0 objects. (4.2, 6.1, 6.6, 7.2). +programs +.\" If the option \fIlisp\fR is set, stops at each \fB(\fR at the +.\" beginning of a line, and is thus useful for moving backwards at the top +.\" level \s-2LISP\s0 objects. +(4.2, 6.1, 6.6, 7.2). .iP "\e" 15 Unused. .iP "]]" 15 -Forward to a section boundary, see \fB[[\fR for a definition (4.2, 6.1, +Forward to a section boundary; see \fB[[\fR for a definition (4.2, 6.1, 6.6, 7.2). -.iP "\(ua" 15 +.iP "^" 15 Moves to the first non-white position on the current line (4.4). .iP "_" 15 Unused. .iP "\(ga" 15 -When followed by a \fB\(ga\fR returns to the previous context. +When followed by a \fB\(ga\fR, returns to the previous context. The previous context is set whenever the current line is moved in a non-relative way. When followed by a letter \fBa\fR\-\fBz\fR, returns to the position which @@ -638,6 +644,4 @@ definition of paragraph (4.2, 6.8, 7.6). Unused. .iP "^?\ (\s-2\fRDEL\fP\s0)" 15 Interrupts the editor, returning it to command accepting state (1.5, -7.5) -.bp -\&. +7.5). diff --git a/usr.bin/vi/docs/USD.doc/vitut/vi.in b/usr.bin/vi/docs/USD.doc/vitut/vi.in index 80fde7b9441..60eb17136b9 100644 --- a/usr.bin/vi/docs/USD.doc/vitut/vi.in +++ b/usr.bin/vi/docs/USD.doc/vitut/vi.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: vi.in,v 1.5 2003/06/03 02:56:22 millert Exp $ +.\" $OpenBSD: vi.in,v 1.6 2004/01/24 12:29:13 jmc Exp $ .\" .\" Copyright (c) 1980, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,11 +29,15 @@ .\" .\" @(#)vi.in 8.5 (Berkeley) 8/18/96 .\" +.if n \{\ +.po 5n +.ll 70n +.\} .nr LL 6.5i .nr FL 6.5i .EH 'USD:11-%''An Introduction to Display Editing with Vi' .OH 'An Introduction to Display Editing with Vi''USD:11-%' -.bd S 3 +.\" .bd S 3 .if t .ds dg \(dg .if n .ds dg + .if t .ds dd \(dd @@ -91,15 +95,15 @@ limited speed available. .PP It is also possible to use the command set of .I vi -on hardcopy terminals, storage tubes and ``glass tty's'' using a one line +on hardcopy terminals, storage tubes and ``glass tty's'' using a one-line editing window; thus -.I vi's +.I vi 's command set is available on all terminals. The full command set of the more traditional, line oriented editor .I ex is available within -.I vi; +.I vi ; it is quite simple to switch between the two modes of editing. .AE .NH 1 @@ -111,15 +115,15 @@ National Science Foundation under grants MCS74-07644-A03 and MCS78-07291 is gratefully acknowledged. .FE This document provides a quick introduction to -.I vi. +.I vi . (Pronounced \fIvee-eye\fP.) You should be running .I vi on a file you are familiar with while you are reading this. The first part of this document (sections 1 through 5) describes the basics of using -.I vi. -Some topics of special interest are presented in section 6, and +.I vi . +Some topics of special interest are presented in section 6, and some nitty-gritty details of how the editor functions are saved for section 7 to avoid cluttering the presentation here. .PP @@ -130,13 +134,13 @@ This card summarizes the commands of .I vi in a very compact format. You should have the card handy while you are learning -.I vi. +.I vi . .NH 2 Specifying terminal type .PP -Before you can start +Before you start .I vi -you must tell the system what kind of terminal you are using. +you can tell the system what kind of terminal you are using. Here is a (necessarily incomplete) list of terminal type codes. If your terminal does not appear here, you should consult with one of the staff members on your system to find out the code for your terminal. @@ -172,37 +176,36 @@ Suppose for example that you have a Hewlett-Packard HP2621A terminal. The code used by the system for this terminal is `2621'. In this case you can use one of the following commands to tell the system the type of your terminal: -.DS -% \fBsetenv TERM\fP 2621 +.DS I +% setenv TERM 2621 .DE This command works with the .I csh shell. If you are using the standard Bourne shell .I sh -then you should give the commands -.DS -$ \fBTERM=\fP2621 -$ \fBexport TERM\fP +then you should give the command: +.DS I +$ export TERM=2621 .DE .PP If you want to arrange to have your terminal type set up automatically when you log in, you can use the -.I tset +.I tset (1) program. If you dial in on a .I mime , but often use hardwired ports, a typical line for your .I .login file (if you use csh) would be -.DS -\fBsetenv TERM \(gatset\fP \- \-d mime\(ga +.DS I +% setenv TERM `tset - -d mime` .DE or for your .I .profile file (if you use sh) -.DS -\fBTERM=\(gatse\fPt \- \-d mime\(ga +.DS I +$ export TERM=`tset - -d mime` .DE .I Tset knows which terminals are hardwired to each port @@ -218,8 +221,8 @@ After telling the system which kind of terminal you have, you should make a copy of a file you are familiar with, and run .I vi on this file, giving the command -.DS -% \fBvi\fR \fIname\fR +.DS I +% vi name .DE replacing \fIname\fR with the name of the copy file you just created. The screen should clear and the text of your file should appear on the @@ -234,7 +237,7 @@ This should get you back to the command level interpreter. Figure out what you did wrong (ask someone else if necessary) and try again. Another thing which can go wrong is that you typed the wrong file name and the editor just printed an error diagnostic. In this case you should -follow the above procedure for getting out of the editor, and try again +follow the above procedure for getting out of the editor and try again, this time spelling the file name correctly. If the editor doesn't seem to respond to the commands which you type here, try sending an interrupt to it by hitting the \s-2DEL\s0 or \s-2RUB\s0 @@ -245,9 +248,9 @@ by a carriage return. .NH 2 The editor's copy: the buffer .PP -The editor does not directly modify the file which you are editing. +The editor does not directly modify the file which you are editing. Rather, the editor makes a copy of this file, in a place called the -.I buffer, +.I buffer , and remembers the file's name. You do not affect the contents of the file unless and until you write the changes you make back into the original file. @@ -267,7 +270,7 @@ will also work within the editor. If you don't have cursor positioning keys, or even if you do, you can use the \fBh j k\fR and \fBl\fR keys as cursor positioning keys (these are labelled with arrows on an -.I adm3a).* +.I adm3a). * .PP (Particular note for the HP2621: on this terminal the function keys must be \fIshifted\fR (ick) to send to the machine, otherwise they @@ -275,14 +278,14 @@ only act locally. Unshifted use will leave the cursor positioned incorrectly.) .FS * As we will see later, -.I h +.B h moves back to the left (like control-h which is a backspace), -.I j +.B j moves down (in the same column), -.I k +.B k moves up (in the same column), and -.I l +.B l moves to the right. .FE .NH 2 @@ -361,15 +364,9 @@ Scrolling and paging The editor has a number of commands for moving around in the file. The most useful of these is generated by hitting the control and D keys at the same time, a control-D or `^D'. We will use this two character -notation for referring to these control keys from now on. You may have -a key labelled `^' on your terminal. This key will be represented as `\(ua' -in this document; `^' is exclusively used as part of the `^x' notation -for control characters.\*(dd -.FS -\*(dd If you don't have a `^' key on your terminal -then there is probably a key labelled `\(ua'; in any case these characters -are one and the same. -.FE +notation for referring to these control keys from now on. +.\" You may have a key labelled `^' on your terminal; +.\" `^' is exclusively used as part of the `^x' notation for control characters. .PP As you know now if you tried hitting \fB^D\fR, this command scrolls down in the file. The \fBD\fR thus stands for down. Many editor commands are mnemonic @@ -414,14 +411,14 @@ or more briefly \fB:se nows\fR\s-2CR\s0. .FE .PP If the search string you give the editor is not present in the -file the editor will print +file, the editor will print a diagnostic on the last line of the screen, and the cursor will be returned to its initial position. .PP If you wish the search to match only at the beginning of a line, begin -the search string with an \fB\(ua\fR. To match only at the end of +the search string with an \fB^\fR. To match only at the end of a line, end the search string with a \fB$\fR. -Thus \fB/\(uasearch\fR\s-2CR\s0 will search for the word `search' at +Thus \fB/^search\fR\s-2CR\s0 will search for the word `search' at the beginning of a line, and \fB/last$\fR\s-2CR\s0 searches for the word `last' at the end of a line.* .FS @@ -673,7 +670,7 @@ You can make small corrections in existing text quite easily. Find a single character which is wrong or just pick any character. Use the arrow keys to find the character, or get near the character with the word motion keys and then either -backspace (hit the \s-2BS\s0 key or \fB^H\fR or even just \fBh\fR) or +backspace (hit the \s-2BS\s0 key or \fB^H\fR or even just \fBh\fR) or \s-2SPACE\s0 (using the space bar) until the cursor is on the character which is wrong. If the character is not needed then hit the \fBx\fP key; this deletes @@ -696,7 +693,7 @@ the number of characters to be deleted. More corrections: operators .PP You already know almost enough to make changes at a higher level. -All you need to know now is that the +All you need to know now is that the .B d key acts as a delete operator. Try the command .B dw @@ -708,13 +705,13 @@ made a change. You can remember it by analogy with an ellipsis `\fB...\fR'. Now try \fBdb\fR. This deletes a word backwards, namely the preceding word. -Try +Try \fBd\fR\s-2SPACE\s0. This deletes a single character, and is equivalent to the \fBx\fR command. .PP Another very useful operator is .B c -or change. The command +or change. The command .B cw thus changes the text of a single word. You follow it by the replacement text ending with an \s-2ESC\s0. @@ -727,7 +724,7 @@ Notice that the end of the text to be changed was marked with the character Operating on lines .PP It is often the case that you want to operate on lines. -Find a line which you want to delete, and type +Find a line which you want to delete, and type \fBdd\fR, the .B d @@ -777,10 +774,10 @@ material back. However, since it is often the case that we regret a change or make a change incorrectly, the editor provides a .B u (undo) command to reverse the last change which you made. -Try this a few times, and give it twice in a row to notice that an +Try this a few times, and give it twice in a row to notice that a .B u also undoes a -.B u. +.B u . .PP The undo command lets you reverse only a single change. After you make a number of changes to a line, you may decide that you would rather have @@ -788,6 +785,13 @@ the original state of the line back. The .B U command restores the current line to the state before you started changing it. +Additionally, an unlimited number of changes may be reversed by following a +.B u +with a +.B . . +Each subsequent +.B . +will undo one more change. .PP You can recover text which you delete, even if undo will not bring it back; see the section on recovering lost text @@ -797,12 +801,12 @@ Summary .IP .TS lw(.50i)b a. -\fR\s-2SPACE\s0\fP advance the cursor one position +\fB\s-2SPACE\s0\fP advance the cursor one position ^H backspace the cursor -^W erase a word during an insert -\fRerase\fP your erase (usually ^H or #), erases a character during an insert -\fRkill\fP your kill (usually @, ^X, or ^U), kills the insert on this line -\&\fB.\fP repeats the changing command +\fBwerase\fP (usually ^W), erase a word during an insert +\fBerase\fP (usually DEL or ^H), erases a character during an insert +\fBkill\fP (usually ^U), kills the insert on this line +\fB.\fP repeats the changing command O opens and inputs new lines, above the current U undoes the changes you made to the current line a appends text after the cursor @@ -819,25 +823,26 @@ Low level character motions .PP Now move the cursor to a line where there is a punctuation or a bracketing character such as a parenthesis or a comma or period. Try the command -\fBf\fR\fIx\fR where \fIx\fR is this character. This command finds +\fBf\fR\fIx\fR, where \fIx\fR is this character. This command finds the next \fIx\fR character to the right of the cursor in the current line. Try then hitting a \fB;\fR, which finds the next instance of the same character. By using the \fBf\fR command and then a sequence of \fB;\fR's you can often get to a particular place in a line much faster than with a sequence of word motions or \s-2SPACE\s0s. -There is also a \fBF\fR command, which is like \fBf\fR, but searches +There is also an \fBF\fR command, which is like \fBf\fR, but searches backward. The \fB;\fR command repeats \fBF\fR also. .PP When you are operating on the text in a line it is often desirable to deal with the characters up to, but not including, the first instance of a character. Try \fBdf\fR\fIx\fR for some \fIx\fR now and -notice that the \fIx\fR character is deleted. Undo this with \fBu\fR -and then try \fBdt\fR\fIx\fR; the \fBt\fR here stands for to, i.e. +notice that the text up to (and including) the \fIx\fR character is deleted. +Undo this with \fBu\fR and then try \fBdt\fR\fIx\fR; +the \fBt\fR here stands for to, i.e. delete up to the next \fIx\fR, but not the \fIx\fR. The command \fBT\fR is the reverse of \fBt\fR. .PP -When working with the text of a single line, an \fB\(ua\fR moves the +When working with the text of a single line, a \fB^\fR moves the cursor to the first non-white position on the line, and a \fB$\fR moves it to the end of the line. Thus \fB$a\fR will append new text at the end of the current line. @@ -847,14 +852,14 @@ characters are represented as a number of spaces expanding to a tab stop, where tab stops are every 8 positions.* .FS * This is settable by a command of the form \fB:se ts=\fR\fIx\fR\s-2CR\s0, -where \fIx\fR is 4 to set tabstops every four columns. This has +where \fIx\fR is 4 to set tabstops every four columns. This has an effect on the screen representation within the editor. .FE When the cursor is at a tab, it sits on the last of the several spaces which represent that tab. Try moving the cursor back and forth over tabs so you understand how this works. .PP -On rare occasions, your file may have nonprinting characters in it. +On rare occasions, your file may have nonprinting characters in it. These characters are displayed in the same way they are represented in this document, that is with a two character code, the first character of which is `^'. On the screen non-printing characters resemble a `^' @@ -928,7 +933,7 @@ The section commands interpret a preceding count as a different window size in which to redraw the screen at the new location, and this window size is the base size for newly drawn windows until another size is specified. This is very useful -if you are on a slow terminal and are looking for a particular section. +if you are on a slow terminal and are looking for a particular section. You can give the first section command a small count to then see each successive section heading in a small window. .NH 2 @@ -947,7 +952,7 @@ If preceded by a buffer name, \fB"\fR\fIx\fR\|\fBy\fR, where buffer. The text can then be put back in the file with the commands .B p and -.B P; +.B P ; \fBp\fR puts the text after or below the cursor, while \fBP\fR puts the text before or above the cursor. .PP @@ -957,7 +962,7 @@ partially spans more than one line, then when you put the text back, it will be placed after the cursor (or before if you use \fBP\fR). If the yanked text forms whole lines, they will be put back as whole lines, without changing the current line. In this case, -the put acts much like a \fBo\fR or \fBO\fR command. +the put acts much like an \fBo\fR or \fBO\fR command. .PP Try the command \fBYP\fR. This makes a copy of the current line and leaves you on this copy, which is placed before the current line. @@ -970,7 +975,7 @@ To move text within the buffer, you need to delete it in one place, and put it back in another. You can precede a delete operation by the name of a buffer in which the text is to be stored as in \fB"a5dd\fR deleting 5 lines into the named buffer \fIa\fR. You can then move the -cursor to the eventual resting place of the these lines and do a \fB"ap\fR +cursor to the eventual resting place of these lines and do a \fB"ap\fR or \fB"aP\fR to put them back. In fact, you can switch and edit another file before you put the lines back, by giving a command of the form \fB:e \fR\fIname\fR\s-2CR\s0 where @@ -981,13 +986,13 @@ to the other file. An ordinary delete command saves the text in the unnamed buffer, so that an ordinary put can move it elsewhere. However, the unnamed buffer is lost when you change files, -so to move text from one file to another you should use an unnamed buffer. +so to move text from one file to another you should use a named buffer. .NH 2 Summary. .IP .TS lw(.50i)b a. -\(ua first non-white on line +^ first non-white on line $ end of line ) forward sentence } forward paragraph @@ -1096,8 +1101,8 @@ On a dumb terminal, if there are @ lines in the middle of the screen as a result of line deletion, you may get rid of these lines by typing \fB^R\fR to cause the editor to retype the screen, closing up these holes. .PP -Finally, if you wish to place a certain line on the screen at the top -middle or bottom of the screen, you can position the cursor to that line, +Finally, if you wish to place a certain line on the screen at the top, +middle, or bottom of the screen, you can position the cursor to that line, and then give a \fBz\fR command. You should follow the \fBz\fR command with a \s-2RETURN\s0 if you want the line to appear at the top of the window, a \fB.\fR if you want it @@ -1113,19 +1118,19 @@ long delays, waiting for the screen to be refreshed. We have already pointed out how the editor optimizes the updating of the screen during insertions on dumb terminals to limit the delays, and how the editor erases lines to @ when they are deleted on dumb terminals. -.PP -The use of the slow terminal insertion mode is controlled by the -.I slowopen -option. You can force the editor to use this mode even on faster terminals -by giving the command \fB:se slow\fR\s-2CR\s0. If your system is sluggish -this helps lessen the amount of output coming to your terminal. -You can disable this option by \fB:se noslow\fR\s-2CR\s0. -.PP -The editor can simulate an intelligent terminal on a dumb one. Try -giving the command \fB:se redraw\fR\s-2CR\s0. This simulation generates -a great deal of output and is generally tolerable only on lightly loaded -systems and fast terminals. You can disable this by giving the command - \fB:se noredraw\fR\s-2CR\s0. +.\" .PP +.\" The use of the slow terminal insertion mode is controlled by the +.\" .I slowopen +.\" option. You can force the editor to use this mode even on faster terminals +.\" by giving the command \fB:se slow\fR\s-2CR\s0. If your system is sluggish, +.\" this helps lessen the amount of output coming to your terminal. +.\" You can disable this option by \fB:se noslow\fR\s-2CR\s0. +.\" .PP +.\" The editor can simulate an intelligent terminal on a dumb one. Try +.\" giving the command \fB:se redraw\fR\s-2CR\s0. This simulation generates +.\" a great deal of output and is generally tolerable only on lightly loaded +.\" systems and fast terminals. You can disable this by giving the command +.\" \fB:se noredraw\fR\s-2CR\s0. .PP The editor also makes editing more pleasant at low speed by starting editing in a small window, and letting the window expand as you edit. @@ -1141,7 +1146,7 @@ which cause large screen motions: .B ": / ? [[ ]] \(ga \(aa" .DE Thus if you are searching for a particular instance of a common string -in a file you can precede the first search command by a small number, +in a file, you can precede the first search command by a small number, say 3, and the editor will draw three line windows around each instance of the string which it locates. .PP @@ -1162,10 +1167,10 @@ what is displayed on the screen. You can still edit the text on the screen if you wish; clear up the confusion by hitting a \fB^L\fR; or move or search again, ignoring the current state of the display. -.PP -See section 7.8 on \fIopen\fR mode for another way to use the -.I vi -command set on slow terminals. +.\" .PP +.\" See section 7.8 on \fIopen\fR mode for another way to use the +.\" .I vi +.\" command set on slow terminals. .NH 2 Options, set, and editor startup files .PP @@ -1190,18 +1195,18 @@ l l l a. Name Default Description _ autoindent noai Supply indentation automatically -autowrite noaw Automatic write before \fB:n\fR, \fB:ta\fR, \fB^\(ua\fR, \fB!\fR +autowrite noaw Automatic write before \fB:n\fR, \fB:ta\fR, \fB^^\fR, \fB!\fR ignorecase noic Ignore case in searching -lisp nolisp \fB( { ) }\fR commands deal with S-expressions -list nolist Tabs print as ^I; end of lines marked with $ -magic nomagic The characters . [ and * are special in scans -number nonu Lines are displayed prefixed with line numbers +.\" lisp nolisp \fB( { ) }\fR commands deal with S-expressions +list nolist Tabs print as ^I; end of lines marked $ +magic nomagic . [ and * are special in scans +number nonu Lines prefixed with line numbers paragraphs para=IPLPPPQPbpP LI Macro names which start paragraphs redraw nore Simulate a smart terminal on a dumb one sections sect=NHSHH HU Macro names which start new sections -shiftwidth sw=8 Shift distance for <, > and input \fB^D\fP and \fB^T\fR +shiftwidth sw=8 Shift distance for <, > and \fB^D\fP and \fB^T\fR showmatch nosm Show matching \fB(\fP or \fB{\fP as \fB)\fP or \fB}\fR is typed -slowopen slow Postpone display updates during inserts +.\" slowopen slow Postpone display updates during inserts term dumb The kind of terminal you are using. .TE .KE @@ -1239,31 +1244,31 @@ be separated with the | character, for example: .DS \fBset\fP ai aw terse|\fBmap\fP @ dd|\fBmap\fP # x .DE -which sets the options \fIautoindent\fP, \fIautowrite\fP, \fIterse\fP, +which sets the options \fIautoindent\fP, \fIautowrite\fP, \fIterse\fP (the .B set command), -makes @ delete a line, +makes @ delete a line (the first .B map ), -and makes # delete a character, +and makes # delete a character (the second .B map ). -(See section 6.9 for a description of the \fBmap\fP command) +(See section 6.9 for a description of the \fBmap\fP command.) This string should be placed in the variable EXINIT in your environment. If you use the shell \fIcsh\fP, put this line in the file .I .login in your home directory: -.DS -setenv EXINIT \(aa\fBset\fP ai aw terse|\fBmap\fP @ dd|\fBmap\fP # x\(aa +.DS I +setenv EXINIT 'set ai aw terse|map @ dd|map # x' .DE If you use the standard shell \fIsh\fP, put these lines in the file .I .profile in your home directory: .DS -EXINIT=\(aa\fBset\fP ai aw terse|\fBmap\fP @ dd|\fBmap\fP # x\(aa +EXINIT='set ai aw terse|map @ dd|map # x' export EXINIT .DE Of course, the particulars of the line would depend on which options @@ -1314,11 +1319,11 @@ Recovering lost files .PP If the system crashes, you can recover the work you were doing to within a few changes. You will normally receive mail when you next -login giving you the name of the file which has been saved for you. +login giving you the name of the file which has been saved for you. You should then change to the directory where you were when the system crashed and give a command of the form: .DS -% \fBvi \-r\fR \fIname\fR +% vi -r name .DE replacing \fIname\fR with the name of the file which you were editing. This will recover your work to a point near where you left off.\*(dg @@ -1333,8 +1338,8 @@ the few lost lines by hand. .PP You can get a listing of the files which are saved for you by giving the command: -.DS -% \fBvi \-r\fR +.DS I +% vi -r .DE If there is more than one instance of a particular file saved, the editor gives you the newest instance each time you recover it. You can thus @@ -1361,24 +1366,24 @@ from the right hand edge of the screen. If the editor breaks an input line and you wish to put it back together you can tell it to join the lines with \fBJ\fR. You can give \fBJ\fR a count of the number of lines to be joined as in \fB3J\fR to join 3 -lines. The editor supplies white space, if appropriate, +lines. The editor supplies whitespace, if appropriate, at the juncture of the joined -lines, and leaves the cursor at this white space. -You can kill the white space with \fBx\fR if you don't want it. +lines, and leaves the cursor at this whitespace. +You can kill the whitespace with \fBx\fR if you don't want it. .NH 2 Features for editing programs .PP The editor has a number of commands for editing programs. The thing that most distinguishes editing of programs from editing of text is the desirability of maintaining an indented structure to the body of -the program. The editor has a +the program. The editor has an .I autoindent facility for helping you generate correctly indented programs. .PP To enable this facility you can give the command \fB:se ai\fR\s-2CR\s0. Now try opening a new line with \fBo\fR and type some characters on the line after a few tabs. If you now start another line, notice that the -editor supplies white space at the beginning of the line to line it up +editor supplies whitespace at the beginning of the line to line it up with the previous line. You cannot backspace over this indentation, but you can use \fB^D\fR key to backtab over the supplied indentation. .PP @@ -1395,7 +1400,7 @@ For shifting lines in the program left and right, there are operators and .B >. These shift the lines you specify right or left by one -.I shiftwidth. +.I shiftwidth . Try .B << and @@ -1423,51 +1428,51 @@ You can run system commands over portions of the buffer using the operator \fB!\fR. You can use this to sort lines in the buffer, or to reformat portions of the buffer with a pretty-printer. -Try typing in a list of random words, one per line and ending them +Try typing in a list of random words, one per line, and ending them with a blank line. Back up to the beginning of the list, and then give the command \fB!}sort\fR\s-2CR\s0. This says to sort the next paragraph of material, and the blank line ends a paragraph. -.NH 2 -Commands for editing \s-2LISP\s0 -.PP -If you are editing a \s-2LISP\s0 program you should set the option -.I lisp -by doing -\fB:se\ lisp\fR\s-2CR\s0. -This changes the \fB(\fR and \fB)\fR commands to move backward and forward -over s-expressions. -The \fB{\fR and \fB}\fR commands are like \fB(\fR and \fB)\fR but don't -stop at atoms. These can be used to skip to the next list, or through -a comment quickly. -.PP -The -.I autoindent -option works differently for \s-2LISP\s0, supplying indent to align at -the first argument to the last open list. If there is no such argument -then the indent is two spaces more than the last level. -.PP -There is another option which is useful for typing in \s-2LISP\s0, the -.I showmatch -option. -Try setting it with -\fB:se sm\fR\s-2CR\s0 -and then try typing a `(' some words and then a `)'. Notice that the -cursor shows the position of the `(' which matches the `)' briefly. -This happens only if the matching `(' is on the screen, and the cursor -stays there for at most one second. -.PP -The editor also has an operator to realign existing lines as though they -had been typed in with -.I lisp -and -.I autoindent -set. This is the \fB=\fR operator. -Try the command \fB=%\fR at the beginning of a function. This will realign -all the lines of the function declaration. -.PP -When you are editing \s-2LISP\s0,, the \fB[[\fR and \fR]]\fR advance -and retreat to lines beginning with a \fB(\fR, and are useful for dealing -with entire function definitions. +.\" .NH 2 +.\" Commands for editing \s-2LISP\s0 +.\" .PP +.\" If you are editing a \s-2LISP\s0 program you should set the option +.\" .I lisp +.\" by doing +.\" \fB:se\ lisp\fR\s-2CR\s0. +.\" This changes the \fB(\fR and \fB)\fR commands to move backward and forward +.\" over s-expressions. +.\" The \fB{\fR and \fB}\fR commands are like \fB(\fR and \fB)\fR but don't +.\" stop at atoms. These can be used to skip to the next list, or through +.\" a comment quickly. +.\" .PP +.\" The +.\" .I autoindent +.\" option works differently for \s-2LISP\s0, supplying indent to align at +.\" the first argument to the last open list. If there is no such argument +.\" then the indent is two spaces more than the last level. +.\" .PP +.\" There is another option which is useful for typing in \s-2LISP\s0, the +.\" .I showmatch +.\" option. +.\" Try setting it with +.\" \fB:se sm\fR\s-2CR\s0 +.\" and then try typing a `(' some words and then a `)'. Notice that the +.\" cursor shows the position of the `(' which matches the `)' briefly. +.\" This happens only if the matching `(' is on the screen, and the cursor +.\" stays there for at most one second. +.\" .PP +.\" The editor also has an operator to realign existing lines as though they +.\" had been typed in with +.\" .I lisp +.\" and +.\" .I autoindent +.\" set. This is the \fB=\fR operator. +.\" Try the command \fB=%\fR at the beginning of a function. This will realign +.\" all the lines of the function declaration. +.\" .PP +.\" When you are editing \s-2LISP\s0,, the \fB[[\fR and \fR]]\fR advance +.\" and retreat to lines beginning with a \fB(\fR, and are useful for dealing +.\" with entire function definitions. .NH 2 Macros .PP @@ -1519,16 +1524,16 @@ or you should escape them with a \fB^V\fR. (It may be necessary to double the \fB^V\fR if the map command is given inside -.I vi, +.I vi , rather than in -.I ex.) +.I ex .) Spaces and tabs inside the .I rhs need not be escaped. .PP Thus to make the \fBq\fR key write and exit the editor, you can give the command -.DS +.DS I :map q :wq\fB^V^V\fP\s-2CR CR\s0 .DE which means that whenever you type \fBq\fR, it will be as though you @@ -1549,7 +1554,7 @@ The first \s-2CR\s0 is part of the the second terminates the : command. .PP Macros can be deleted with -.DS +.DS I unmap lhs .DE .PP @@ -1560,7 +1565,7 @@ instead of the 2 character ``#'' sequence. So that terminals without function keys can access such definitions, the form ``#x'' will mean function key .I x -on all terminals (and need not be typed within one second.) +on all terminals (and need not be typed within one second). The character ``#'' can be changed by using a macro in the usual way: .DS :map \fB^V^V^I\fP # @@ -1569,9 +1574,11 @@ to use tab, for example. (This won't affect the .I map command, which still uses .B #, -but just the invocation from visual mode. +but just the invocation from visual mode.) .PP -The undo command reverses an entire macro call as a unit, +The +.I undo +command reverses an entire macro call as a unit, if it made any changes. .PP Placing a `!' after the word @@ -1587,7 +1594,7 @@ where .B \o'b/' is a blank. The \fB^V\fP is necessary to prevent the blanks from being taken as -white space between the +whitespace between the .I lhs and .I rhs . @@ -1721,14 +1728,14 @@ More file manipulation commands .PP The following table lists the file manipulation commands which you can use when you are in -.I vi. +.I vi . .KF .DS .TS lb l. :w write back changes :wq write and quit -:x write (if necessary) and quit (same as ZZ). +:x write (if necessary) and quit (same as ZZ) :e \fIname\fP edit file \fIname\fR :e! reedit, discarding changes :e + \fIname\fP edit, starting at end @@ -1800,9 +1807,9 @@ command. If you are editing large programs, you will find the \fB:ta\fR command very useful. It utilizes a data base of function names and their locations, which can be created by programs such as -.I ctags, +.I ctags , to quickly find a function whose name you give. -If the \fB:ta\fR command will require the editor to switch files, then +If the \fB:ta\fR command requires the editor to switch files, then you must \fB:w\fR or abandon any changes before switching. You can repeat the \fB:ta\fR command without any arguments to look for the same tag again. @@ -1832,8 +1839,8 @@ If you do not want or need this facility, you should set nomagic .DE in your EXINIT. -In this case, -only the characters \fB\(ua\fR and \fB$\fR are special in patterns. +In this case, +only the characters \fB^\fR and \fB$\fR are special in patterns. The character \fB\e\fR is also then special (as it is most everywhere in the system), and may be used to get at the an extended pattern matching facility. @@ -1843,13 +1850,13 @@ The following table gives the extended forms when \fBmagic\fR is set. .DS .TS lb l. -\(ua at beginning of pattern, matches beginning of line +^ at beginning of pattern, matches beginning of line $ at end of pattern, matches end of line \fB\&.\fR matches any character \e< matches the beginning of a word \e> matches the end of a word [\fIstr\fP] matches any single character in \fIstr\fP -[\(ua\fIstr\fP] matches any single character not in \fIstr\fP +[^\fIstr\fP] matches any single character not in \fIstr\fP [\fIx\fP\-\fIy\fP] matches any character between \fIx\fP and \fIy\fP * matches any number of the preceding pattern .TE @@ -1876,7 +1883,7 @@ kill your kill character, deletes the input on this line \s-2CR\s0 starts a new line ^D backtabs over \fIautoindent\fP 0^D kills all the \fIautoindent\fP -\(ua^D same as \fB0^D\fP, but restores indent next line +^^D same as \fB0^D\fP, but restores indent next line ^V quotes the next non-printing character into the file .TE .DE @@ -1902,7 +1909,7 @@ If you wish to type in your erase or kill character (say # or @) then you must precede it with a \fB\e\fR, just as you would do at the normal system command level. A more general way of typing non-printing characters into the file is to precede them with a \fB^V\fR. The \fB^V\fR echoes -as a \fB\(ua\fR character on which the cursor rests. This indicates that +as a \fB^\fR character on which the cursor rests. This indicates that the editor expects you to type a control character. In fact you may type any character and it will be inserted into the file at that point.* .FS @@ -1911,7 +1918,7 @@ not allow the \s-2NULL\s0 (\fB^@\fR) character to appear in files. Also the \s-2LF\s0 (linefeed or \fB^J\fR) character is used by the editor to separate lines in the file, so it cannot appear in the middle of a line. You can insert any other character, however, if you wait for the -editor to echo the \fB\(ua\fR before you type the character. In fact, +editor to echo the \fB^\fR before you type the character. In fact, the editor will treat a following letter as a request for the corresponding control character. This is the only way to type \fB^S\fR or \fB^Q\fP, since the system normally uses them to suspend and resume output @@ -1924,7 +1931,7 @@ boundary. This only works immediately after the supplied \fIautoindent\fR. .PP When you are using \fIautoindent\fR you may wish to place a label at -the left margin of a line. The way to do this easily is to type \fB\(ua\fR +the left margin of a line. The way to do this easily is to type \fB^\fR and then \fB^D\fR. The editor will move the cursor to the left margin for one line, and restore the previous indent on the next. You can also type a \fB0\fR followed immediately by a \fB^D\fR if you wish to kill @@ -1939,7 +1946,7 @@ system convention for typing on such a terminal. Characters which you normally type are converted to lower case, and you can type upper case letters by preceding them with a \e. The characters { ~ } | \(ga are not available on such terminals, but you -can escape them as \e( \e\(ua \e) \e! \e\(aa. +can escape them as \e( \e^ \e) \e! \e\(aa. These characters are represented on the display in the same way they are typed.\*(dd .FS @@ -1951,7 +1958,7 @@ Vi and ex .PP .I Vi is actually one mode of editing within the editor -.I ex. +.I ex . When you are running .I vi you can escape to the line oriented editor of @@ -1966,13 +1973,13 @@ Likewise, most .I ex commands can be invoked from .I vi -using :. +using \fB:\fR. Just give them without the \fB:\fR and follow them with a \s-2CR\s0. .PP In rare instances, an internal error may occur in -.I vi. +.I vi . In this case you will get a diagnostic and be left in the command mode of -.I ex. +.I ex . You can then save your work and quit if you wish by giving a command \fBx\fR after the \fB:\fR which \fIex\fR prompts you with, or you can reenter \fIvi\fR by giving @@ -1995,72 +2002,72 @@ users often mix their use of command mode and .I vi command mode to speed the work they are doing. -.NH 2 -Open mode: vi on hardcopy terminals and ``glass tty's'' -\(dd -.PP -If you are on a hardcopy terminal or a terminal which does not have a cursor -which can move off the bottom line, you can still use the command set of -.I vi, -but in a different mode. -When you give a -.I vi -command, the editor will tell you that it is using -.I open -mode. -This name comes from the -.I open -command in -.I ex, -which is used to get into the same mode. -.PP -The only difference between -.I visual -mode -and -.I open -mode is the way in which the text is displayed. -.PP -In -.I open -mode the editor uses a single line window into the file, and moving backward -and forward in the file causes new lines to be displayed, always below the -current line. -Two commands of -.I vi -work differently in -.I open: -.B z -and -\fB^R\fR. -The -.B z -command does not take parameters, but rather draws a window of context around -the current line and then returns you to the current line. -.PP -If you are on a hardcopy terminal, -the -.B ^R -command will retype the current line. -On such terminals, the editor normally uses two lines to represent the -current line. -The first line is a copy of the line as you started to edit it, and you work -on the line below this line. -When you delete characters, the editor types a number of \e's to show -you the characters which are deleted. The editor also reprints the current -line soon after such changes so that you can see what the line looks -like again. -.PP -It is sometimes useful to use this mode on very slow terminals which -can support -.I vi -in the full screen mode. -You can do this by entering -.I ex -and using an -.I open -command. -.LP +.\" .NH 2 +.\" Open mode: vi on hardcopy terminals and ``glass tty's'' +.\" \(dd +.\" .PP +.\" If you are on a hardcopy terminal or a terminal which does not have a cursor +.\" which can move off the bottom line, you can still use the command set of +.\" .I vi, +.\" but in a different mode. +.\" When you give a +.\" .I vi +.\" command, the editor will tell you that it is using +.\" .I open +.\" mode. +.\" This name comes from the +.\" .I open +.\" command in +.\" .I ex, +.\" which is used to get into the same mode. +.\" .PP +.\" The only difference between +.\" .I visual +.\" mode +.\" and +.\" .I open +.\" mode is the way in which the text is displayed. +.\" .PP +.\" In +.\" .I open +.\" mode the editor uses a single line window into the file, and moving backward +.\" and forward in the file causes new lines to be displayed, always below the +.\" current line. +.\" Two commands of +.\" .I vi +.\" work differently in +.\" .I open: +.\" .B z +.\" and +.\" \fB^R\fR. +.\" The +.\" .B z +.\" command does not take parameters, but rather draws a window of context around +.\" the current line and then returns you to the current line. +.\" .PP +.\" If you are on a hardcopy terminal, +.\" the +.\" .B ^R +.\" command will retype the current line. +.\" On such terminals, the editor normally uses two lines to represent the +.\" current line. +.\" The first line is a copy of the line as you started to edit it, and you work +.\" on the line below this line. +.\" When you delete characters, the editor types a number of \e's to show +.\" you the characters which are deleted. The editor also reprints the current +.\" line soon after such changes so that you can see what the line looks +.\" like again. +.\" .PP +.\" It is sometimes useful to use this mode on very slow terminals which +.\" can support +.\" .I vi +.\" in the full screen mode. +.\" You can do this by entering +.\" .I ex +.\" and using an +.\" .I open +.\" command. +.\" .LP .SH Acknowledgements .PP diff --git a/usr.bin/vi/docs/USD.doc/vitut/vi.summary b/usr.bin/vi/docs/USD.doc/vitut/vi.summary index 308a6ce0915..92da835a1d1 100644 --- a/usr.bin/vi/docs/USD.doc/vitut/vi.summary +++ b/usr.bin/vi/docs/USD.doc/vitut/vi.summary @@ -1,4 +1,4 @@ -.\" $OpenBSD: vi.summary,v 1.5 2003/06/03 02:56:22 millert Exp $ +.\" $OpenBSD: vi.summary,v 1.6 2004/01/24 12:29:13 jmc Exp $ .\" .\" Copyright (c) 1980, 1993 .\" The Regents of the University of California. All rights reserved. @@ -135,8 +135,8 @@ $ last \fIx\fP-\fIn\fP \fIn\fP before \fIx\fP .TS aw(1.7i)b aw(1.5i). % setenv TERM \fItype\fP \fIcsh\fP and all version 6 -$ TERM=\fItype\fP; export TERM \fIsh\fP in Version 7 -See also \fItset\fR(1) +$ export TERM=\fItype\fP \fIsh\fP in Version 7 +\fRSee also\fP \fItset\fR(1) .TE .h "Some terminal types" .TS @@ -151,7 +151,7 @@ lw(.4i) lw(.4i) lw(.4i) lw(.4i) lw(.4i). .h "Initializing options" .TS lw(.9i)b aw(1.5i). -EXINIT place \fBset\fP's here in environment var. +EXINIT place \fBset\fP's here in environment var set \fIx\fP enable option set no\fIx\fP disable option set \fIx\fP=\fIval\fP give value \fIval\fP @@ -165,7 +165,7 @@ lw(.9i)b lw(.3i) lw(1.0i). autoindent ai supply indent autowrite aw write before changing files ignorecase ic in scanning -lisp \fB( ) { }\fP are s-exp's +.\" lisp \fB( ) { }\fP are s-exp's list print ^I for tab, $ at end magic \fB. [ *\fP special in patterns number nu number lines @@ -175,7 +175,7 @@ scroll command mode lines sections sect macro names ... shiftwidth sw for \fB< >\fP, and input \fB^D\fP showmatch sm to \fB)\fP and \fB}\fP as typed -slowopen slow choke updates during insert +.\" slowopen slow choke updates during insert window visual mode lines wrapscan ws around end of buffer? wrapmargin wm automatic line splitting @@ -184,13 +184,13 @@ wrapmargin wm automatic line splitting .h "Scanning pattern formation" .TS aw(.9i)b aw(1.0i). -\(ua beginning of line +^ beginning of line $ end of line \fB.\fR any character \e< beginning of word \e> end of word [\fIstr\fP] any char in \fIstr\fP -[\(ua\fIstr\fP] ... not in \fIstr\fP +[^\fIstr\fP] ... not in \fIstr\fP [\fIx\-y\fP] ... between \fIx\fP and \fIy\fP * any number of preceding .TE @@ -253,7 +253,7 @@ T} .h "Counts before vi commands" .TS lw(1.5i) lw(1.7i)b. -line/column number z G | +line/column number z G | scroll amount ^D ^U replicate insert a i A I repeat effect \fRmost rest\fP @@ -290,7 +290,7 @@ aw(0.75i)b aw(1.6i). :e + \fIname\fP edit, starting at end :e +\fIn\fR edit starting at line \fIn\fR :e # edit alternate file -^\(ua synonym for \fB:e #\fP +^^ synonym for \fB:e #\fP :w \fIname\fP write file \fIname\fP :w! \fIname\fP overwrite file \fIname\fP :sh run shell, then return @@ -352,13 +352,13 @@ M middle window line + next line, at first non-white \- previous line, at first non-white \fRCR\fP return, same as + -\(da \fRor\fP j next line, same column -\(ua \fRor\fP k previous line, same column +^J \fRor\fP j next line, same column +^ \fRor\fP k previous line, same column .TE .h "Character positioning" .TS aw(0.5i)b aw(2.0i). -\(ua first non white +^ first non white 0 beginning of line $ end of line h \fRor\fP \(-> forward @@ -408,7 +408,7 @@ aw(.5i)b aw(2.0i). \fRESC\fP ends insertion, back to command ^? interrupt, terminates insert ^D backtab over \fIautoindent\fP -\(ua^D kill \fIautoindent\fP, save for next +^^D kill \fIautoindent\fP, save for next 0^D ... but at margin next also ^V quote non-printing character .TE |