|
|
1.1 ! root 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 are permitted ! 5: .\" provided that the above copyright notice and this paragraph are ! 6: .\" duplicated in all such forms and that any documentation, ! 7: .\" advertising materials, and other materials related to such ! 8: .\" distribution and use acknowledge that the software was developed ! 9: .\" by the University of California, Berkeley. The name of the ! 10: .\" University may not be used to endorse or promote products derived ! 11: .\" from this software without specific prior written permission. ! 12: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 13: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 14: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 15: .\" ! 16: .\" @(#)vi.apwh.ms 6.2 (Berkeley) 11/27/89 ! 17: .\" ! 18: .TL ! 19: Vi Command & Function Reference ! 20: .AU CB 2675 ! 21: Alan P.W. Hewett ! 22: .sp ! 23: Revised for version 2.12 by Mark Horton ! 24: .CB ! 25: .NH 1 ! 26: Author's Disclaimer ! 27: .LP ! 28: This document does not claim to be 100% complete. There are a ! 29: few commands listed in the original document that I was unable ! 30: to test either because I do not speak \fBlisp\fR, because they ! 31: required programs we don't have, or because I wasn't able to make ! 32: them work. In these cases I left the command out. The commands ! 33: listed in this document have been tried and are known to work. ! 34: It is expected that prospective users of this document will read ! 35: it once to get the flavor of everything that \fBvi\fR can do ! 36: and then use it as a reference document. Experimentation is ! 37: recommended. If you don't understand a command, try it and ! 38: see what happens. ! 39: .LP ! 40: [Note: In revising this document, I have attempted to make it ! 41: completely reflect version 2.12 of ! 42: .B vi . ! 43: It does not attempt to document the VAX version (version 3), ! 44: but with one or two exceptions (wrapmargin, arrow keys) ! 45: everything said about 2.12 should apply to 3.1. ! 46: .I "Mark Horton" ] ! 47: .NH 1 ! 48: Notation ! 49: .LP ! 50: \fB[option]\fR is used to denote optional parts of a command. ! 51: Many \fBvi\fR commands have an optional count. \fB[cnt]\fR ! 52: means that an optional number may precede the command to ! 53: multiply or iterate the command. ! 54: \fB{variable item}\fR is used to denote parts of the command ! 55: which must appear, but can take a number of different values. ! 56: \fB<character [-character]>\fR means that the character or ! 57: one of the characters in the range described between the ! 58: two angle brackets is to be typed. ! 59: For example \fB<esc>\fR means ! 60: the \fBescape\fR key is to be typed. \fB<a-z>\fR means that a ! 61: lower case letter is to be typed. \fB^<character>\fR means that ! 62: the character is to be typed as a \fBcontrol\fR character, that is, ! 63: with the \fB<cntl>\fR key held down while simultaneously typing ! 64: the specified character. In this document control characters will ! 65: be denoted using the \fIupper case\fR character, but ! 66: ^<uppercase chr> and ^<lowercase chr> are equivalent. That is, for ! 67: example, \fB<^D>\fR is equal to \fB<^d>\fR. ! 68: The most common character abbreviations ! 69: used in this list are as follows: ! 70: .VL 8 ! 71: .IP <esc> 8 ! 72: escape, octal 033 ! 73: .IP <cr> 8 ! 74: carriage return, ^M, octal 015 ! 75: .IP <lf> 8 ! 76: linefeed ^J, octal 012 ! 77: .IP <nl> 8 ! 78: newline, ^J, octal 012 (same as linefeed) ! 79: .IP <bs> 8 ! 80: backspace, ^H, octal 010 ! 81: .IP <tab> 8 ! 82: tab, ^I, octal 011 ! 83: .IP <bell> 8 ! 84: bell, ^G, octal 07 ! 85: .IP <ff> 8 ! 86: formfeed, ^L, octal 014 ! 87: .IP <sp> 8 ! 88: space, octal 040 ! 89: .IP <del> 8 ! 90: delete, octal 0177 ! 91: .LE ! 92: .sp 1 ! 93: .NH 1 ! 94: Basics ! 95: .LP ! 96: To run \fBvi\fR the shell variable \fBTERM\fR must be defined and ! 97: exported to your environment. ! 98: How you do this depends on which shell you are using. ! 99: You can tell which shell you have by the character it ! 100: prompts you for commands with. ! 101: The Bourne shell prompts with `$', and the C shell prompts with `%'. ! 102: For these examples, we will suppose ! 103: that you are using an HP 2621 terminal, whose termcap name is ``2621''. ! 104: .NH 2 ! 105: Bourne Shell ! 106: .LP ! 107: To manually set your terminal type to 2621 you would type: ! 108: .DS ! 109: TERM=2621 ! 110: export TERM ! 111: .DE ! 112: .PP ! 113: There are various ways of having this automatically or ! 114: semi-automatically done when you log in. ! 115: Suppose you usually dial in on a 2621. ! 116: You want to tell this to the machine, but still have it ! 117: work when you use a hardwired terminal. ! 118: The recommended way, if you have the ! 119: .B tset ! 120: program, is to use the sequence ! 121: .DS ! 122: tset \-s \-d 2621 > tset$$ ! 123: \&. tset$$ ! 124: rm tset$$ ! 125: .DE ! 126: in your .login (for csh) or the same thing using `.' instead of `source' ! 127: in your .profile (for sh). ! 128: The above line says that if you are dialing in you are on a 2621, ! 129: but if you are on a hardwired terminal it figures out your terminal ! 130: type from an on-line list. ! 131: .NH 2 ! 132: The C Shell ! 133: .LP ! 134: To manually set your terminal type to 2621 you would type: ! 135: .DS ! 136: setenv TERM 2621 ! 137: .DE ! 138: .PP ! 139: There are various ways of having this automatically or ! 140: semi-automatically done when you log in. ! 141: Suppose you usually dial in on a 2621. ! 142: You want to tell this to the machine, but still have it ! 143: work when you use a hardwired terminal. ! 144: The recommended way, if you have the ! 145: .B tset ! 146: program, is to use the sequence ! 147: .DS ! 148: tset \-s \-d 2621 > tset$$ ! 149: source tset$$ ! 150: rm tset$$ ! 151: .DE ! 152: in your .login.* ! 153: .FS ! 154: * On a version 6 system ! 155: without environments, the invocation of tset ! 156: is simpler, just add the line ``tset \-d 2621'' ! 157: to your .login or .profile. ! 158: .FE ! 159: The above line says that if you are dialing in you are on a 2621, ! 160: but if you are on a hardwired terminal it figures out your terminal ! 161: type from an on-line list. ! 162: .NH 1 ! 163: Normal Commands ! 164: .LP ! 165: \fBVi\fR is a visual editor with a window on the file. What ! 166: you see on the screen is \fBvi\fR's current notion of ! 167: what your file will contain, ! 168: (at this point in the file), ! 169: when it is written out. ! 170: Most commands do not cause any change in the screen until the ! 171: complete command is typed. Should you get confused while ! 172: typing a command, you can abort the command by typing an ! 173: <del> character. You will know you are back to command level ! 174: when you hear a <bell>. Usually typing an <esc> will produce the ! 175: same result. When \fBvi\fR gets an improperly formatted command ! 176: it rings the <bell>. ! 177: Following are the \fBvi\fR commands broken down by function. ! 178: .NH 2 ! 179: Entry and Exit ! 180: .LP ! 181: To enter ! 182: .B vi ! 183: on a particular ! 184: .I file , ! 185: type ! 186: .DS ! 187: \fBvi\fP \fIfile\fP ! 188: .DE ! 189: The file will be read in and the cursor will be placed at the beginning ! 190: of the first line. ! 191: The first screenfull of the file will be displayed on the terminal. ! 192: .PP ! 193: To get out of the editor, type ! 194: .DS ! 195: ZZ ! 196: .DE ! 197: If you are in some special mode, such as input mode ! 198: or the middle of a multi-keystroke command, it may ! 199: be necessary to type <esc> first. ! 200: .NH 2 ! 201: Cursor and Page Motion ! 202: .LP ! 203: .VL 16 ! 204: .B NOTE: ! 205: The arrow keys (see the next four commands) ! 206: on certain kinds of terminals will not work with the ! 207: PDP-11 version of vi. The control versions or the hjkl versions will ! 208: work on any terminal. Experienced users prefer the hjkl keys because ! 209: they are always right under their fingers. Beginners often prefer ! 210: the arrow keys, since they do not require memorization of which hjkl ! 211: key is which. ! 212: The mnemonic value of hjkl is clear from looking at the keyboard of an adm3a. ! 213: .sp ! 214: .IP "[cnt]<bs> or [cnt]h or [cnt]\(<-" 16 ! 215: .br ! 216: Move the cursor to the left one character. Cursor stops at the left ! 217: margin of the page. ! 218: If cnt is given, these commands move that many spaces. ! 219: .IP "[cnt]^N or [cnt]j or [cnt]\(da or [cnt]<lf>" 16 ! 220: .br ! 221: Move down one line. ! 222: Moving off the screen scrolls the window to force a new line ! 223: onto the screen. ! 224: Mnemonic: \fBN\fRext ! 225: .IP "[cnt]^P or [cnt]k or [cnt]\(ua" 16 ! 226: .br ! 227: Move up one line. ! 228: Moving off the top of the screen forces new text onto the screen. ! 229: Mnemonic: \fBP\fRrevious ! 230: .IP "[cnt]<sp> or [cnt]l or [cnt]\(->" 16 ! 231: .br ! 232: Move to the right one character. ! 233: Cursor will not go beyond the end of the line. ! 234: .IP [cnt]- 16 ! 235: Move the cursor up the screen to the beginning of the next line. ! 236: Scroll if necessary. ! 237: .IP "[cnt]+ or [cnt]<cr>" 16 ! 238: .sp 1 ! 239: Move the cursor down the screen to the beginning of the next line. ! 240: Scroll up if necessary. ! 241: .IP "[cnt]$" 16 ! 242: Move the cursor to the end of the line. ! 243: If there is a count, move to the end of the line "cnt" lines ! 244: forward in the file. ! 245: .IP "^" 16 ! 246: Move the cursor to the beginning of the first word on the line. ! 247: .IP "0" 16 ! 248: Move the cursor to the left margin of the current line. ! 249: .IP "[cnt]|" 16 ! 250: Move the cursor to the column specified by the count. The default is ! 251: column zero. ! 252: .IP "[cnt]w" 16 ! 253: Move the cursor to the beginning of the next word. If there ! 254: is a count, then move forward that many words and ! 255: position the cursor at the beginning of the word. ! 256: Mnemonic: next-\fBw\fRord ! 257: .IP "[cnt]W" 16 ! 258: Move the cursor to the beginning of the next word which follows ! 259: a "white space" (<sp>,<tab>, or <nl>). Ignore other punctuation. ! 260: .IP "[cnt]b" 16 ! 261: Move the cursor to the preceding word. Mnemonic: \fBb\fRackup-word ! 262: .IP "[cnt]B" 16 ! 263: Move the cursor to the preceding word that is separated from the ! 264: current word by a "white space" (<sp>,<tab>, or <nl>). ! 265: .IP "[cnt]e" 16 ! 266: Move the cursor to the end of the current word or the end of the ! 267: "cnt"'th word hence. Mnemonic: \fBe\fRnd-of-word ! 268: .IP "[cnt]E" 16 ! 269: Move the cursor to the end of the current word which is delimited by ! 270: "white space" (<sp>,<tab>, or <nl>). ! 271: .IP "[line number]G" 16 ! 272: .br ! 273: Move the cursor to the line specified. Of particular use are the ! 274: sequences "1G" and "G", which move the cursor to the beginning and ! 275: the end of the file respectively. Mnemonic: \fBG\fRo-to ! 276: .LP ! 277: .B NOTE: ! 278: The next four commands (^D, ^U, ^F, ^B) ! 279: are not true motion commands, in that they ! 280: cannot be used as the object of commands such as delete or change. ! 281: .IP "[cnt]^D" 16 ! 282: Move the cursor down in the file by "cnt" lines (or the last "cnt" ! 283: if a new count isn't given. The initial default is half a page.) The ! 284: screen is simultaneously scrolled up. Mnemonic: \fBD\fRown ! 285: .IP "[cnt]^U" 16 ! 286: Move the cursor up in the file by "cnt" lines. The screen is simultaneously ! 287: scrolled down. Mnemonic: \fBU\fRp ! 288: .IP "[cnt]^F" 16 ! 289: Move the cursor to the next page. A count moves that many pages. ! 290: Two lines of the previous page are kept on the screen for continuity if ! 291: possible. Mnemonic: \fBF\fRorward-a-page ! 292: .IP "[cnt]^B" 16 ! 293: Move the cursor to the previous page. Two lines of the current page ! 294: are kept if possible. Mnemonic: \fBB\fRackup-a-page ! 295: .IP "[cnt](" 16 ! 296: Move the cursor to the beginning of the next sentence. ! 297: A sentence is defined as ending with a ".", "!", or "?" ! 298: followed by two spaces or a <nl>. ! 299: .IP "[cnt])" 16 ! 300: Move the cursor backwards to the beginning of a sentence. ! 301: .IP "[cnt]}" 16 ! 302: Move the cursor to the beginning of the next paragraph. This command ! 303: works best inside \fBnroff\fR documents. It understands two sets of ! 304: \fBnroff\fR macros, \fB\-ms\fR and \fB\-mm\fR, for which the ! 305: commands ".IP", ".LP", ".PP", ".QP", "P", as well as the nroff command ".bp" ! 306: are considered to be paragraph delimiters. ! 307: A blank line also delimits a paragraph. ! 308: The \fBnroff\fR macros that it accepts as paragraph delimiters is ! 309: adjustable. See \fBparagraphs\fR under the \fBSet Commands\fR section. ! 310: .IP "[cnt]{" 16 ! 311: Move the cursor backwards to the beginning of a paragraph. ! 312: .IP "]]" 16 ! 313: Move the cursor to the next "section", where a section is defined by ! 314: two sets of \fBnroff\fR macros, \fB\-ms\fR and \fB\-mm\fR, in which ! 315: ".NH", ".SH", and ".H" delimit a section. A line beginning with a <ff><nl> ! 316: sequence, or a line beginning with a "{" are also considered to ! 317: be section delimiters. The last option makes it ! 318: useful for finding the beginnings of C functions. ! 319: The \fBnroff\fR macros that are used for section delimiters can be adjusted. ! 320: See \fBsections\fR under the \fBSet Commands\fR section. ! 321: .IP "[[" 16 ! 322: Move the cursor backwards to the beginning of a section. ! 323: .IP "%" 16 ! 324: Move the cursor to the matching parenthesis ! 325: or brace. This is very useful in C or lisp code. If the ! 326: cursor is sitting on a \fB( ) {\fR or \fB}\fR the cursor ! 327: is moved to the matching character at the other end of the ! 328: section. If the cursor is not sitting on a brace or a ! 329: parenthesis, \fBvi\fR searches forward until it finds one ! 330: and then jumps to the match mate. ! 331: .IP "[cnt]H" 16 ! 332: If there is no count move the cursor to the top left position on the screen. ! 333: If there is a count, then move the cursor to the beginning of the line ! 334: "cnt" lines from the top of the screen. Mnemonic: \fBH\fRome ! 335: .IP "[cnt]L" 16 ! 336: If there is no count move the cursor to the beginning ! 337: of the last line on the screen. ! 338: If there is a count, then move the cursor to the beginning of the line ! 339: "cnt" lines from the bottom of the screen. Mnemonic: \fBL\fRast ! 340: .IP "M" 16 ! 341: Move the cursor to the beginning of the middle line on the screen. ! 342: Mnemonic: \fBM\fRiddle ! 343: .IP "m<a-z>" 16 ! 344: This command does not move the cursor, but it \fBmarks\fR the place ! 345: in the file and the character "<a-z>" becomes the label for referring ! 346: to this location in the file. See the next two commands. Mnemonic: ! 347: \fBm\fRark ! 348: .B NOTE: ! 349: The mark command is not a motion, and cannot be used as the target ! 350: of commands such as delete. ! 351: .IP "\(aa<a-z>" 16 ! 352: Move the cursor to the beginning of the line that is marked with the label ! 353: "<a-z>". ! 354: .IP "\(ga<a-z>" 16 ! 355: Move the cursor to the exact position on the line that was marked with ! 356: with the label "<a-z>". ! 357: .IP "\(aa\(aa" 16 ! 358: Move the cursor back to the beginning of the line where it was before the ! 359: last "non-relative" move. A "non-relative" move is something such as a ! 360: search or a jump to a specific line in the file, rather than moving the ! 361: cursor or scrolling the screen. ! 362: .IP "\(ga\(ga" 16 ! 363: Move the cursor back to the exact spot on the line where it was located ! 364: before the last "non-relative" move. ! 365: .LE ! 366: .NH 2 ! 367: Searches ! 368: .LP ! 369: The following commands allow you to search for items in a file. ! 370: .VL 16 ! 371: .IP [cnt]f{chr} 16 ! 372: .sp 1 ! 373: Search forward on the line for the next or "cnt"'th occurrence of ! 374: the character "chr". The cursor is placed \fBat\fR the character ! 375: of interest. Mnemonic: \fBf\fRind character ! 376: .IP [cnt]F{chr} 16 ! 377: .sp 1 ! 378: Search backwards on the line for the next or "cnt"'th occurrence of ! 379: the character "chr". The cursor is placed \fBat\fR the character ! 380: of interest. ! 381: .IP [cnt]t{chr} 16 ! 382: .sp 1 ! 383: Search forward on the line for the next or "cnt"'th occurrence of ! 384: the character "chr". The cursor is placed \fBjust preceding\fR ! 385: the character of interest. Mnemonic: move cursor up \fBt\fRo character ! 386: .IP [cnt]T{chr} 16 ! 387: .sp 1 ! 388: Search backwards on the line for the next or "cnt"'th occurrence of ! 389: the character "chr". The cursor is placed \fBjust preceding\fR ! 390: the character of interest. ! 391: .IP "[cnt];" 16 ! 392: Repeat the last "f", "F", "t" or "T" command. ! 393: .IP "[cnt]," 16 ! 394: Repeat the last "f", "F", "t" or "T" command, but in the opposite ! 395: search direction. This is useful if you overshoot. ! 396: .IP "[cnt]/[string]/<nl>" 16 ! 397: .br ! 398: Search forward for the next occurrence of "string". ! 399: Wrap around at the end of the file ! 400: does occur. ! 401: The final \fB</>\fR is not required. ! 402: .IP "[cnt]?[string]?<nl>" 16 ! 403: .br ! 404: Search backwards for the next occurrence of "string". If a count is ! 405: specified, the count becomes the new window size. Wrap around at the beginning ! 406: of the file does occur. ! 407: The final \fB<?>\fR is not required. ! 408: .IP n 16 ! 409: Repeat the last /[string]/ or ?[string]? search. Mnemonic: \fBn\fRext ! 410: occurrence. ! 411: .IP N 16 ! 412: Repeat the last /[string]/ or ?[string]? search, but in the reverse ! 413: direction. ! 414: .IP ":g/[string]/[editor command]<nl>" 16 ! 415: .sp 1 ! 416: Using the \fB:\fR syntax it is possible to do global searches ala the ! 417: standard UNIX "ed" editor. ! 418: .LE ! 419: .NH 2 ! 420: Text Insertion ! 421: .LP ! 422: The following commands allow for the insertion of text. All multicharacter ! 423: text insertions are terminated with an <esc> character. ! 424: The last change ! 425: can always be \fBundone\fR by typing a \fBu\fR. ! 426: The text insert in insertion mode can contain newlines. ! 427: .VL 16 ! 428: .IP a{text}<esc> 16 ! 429: Insert text immediately following the cursor position. ! 430: Mnemonic: \fBa\fRppend ! 431: .IP A{text}<esc> 16 ! 432: Insert text at the end of the current line. ! 433: Mnemonic: \fBA\fRppend ! 434: .IP i{text}<esc> 16 ! 435: Insert text immediately preceding the cursor position. ! 436: Mnemonic: \fBi\fRnsert ! 437: .IP I{text}<esc> 16 ! 438: Insert text at the beginning of the current line. ! 439: .IP o{text}<esc> 16 ! 440: Insert a new line after the line on which the cursor appears and ! 441: insert text there. Mnemonic: \fBo\fRpen new line ! 442: .IP O{text}<esc> 16 ! 443: Insert a new line preceding the line on which the cursor appears ! 444: and insert text there. ! 445: .LE ! 446: .NH 2 ! 447: Text Deletion ! 448: .LP ! 449: The following commands allow the user to delete text in various ways. ! 450: All changes can always be \fBundone\fR by typing the \fBu\fR command. ! 451: .VL 16 ! 452: .IP "[cnt]x" 16 ! 453: Delete the character or characters starting at the cursor position. ! 454: .IP "[cnt]X" 16 ! 455: Delete the character or characters starting at the character preceding ! 456: the cursor position. ! 457: .IP "D" 16 ! 458: Deletes the remainder of the line starting at the cursor. ! 459: Mnemonic: \fBD\fRelete the rest of line ! 460: .IP "[cnt]d{motion}" 16 ! 461: .br ! 462: Deletes one or more occurrences of the specified motion. ! 463: Any motion from sections 4.1 and 4.2 can be used here. ! 464: The d can be stuttered (e.g. [cnt]dd) to delete cnt lines. ! 465: .LE ! 466: .NH 2 ! 467: Text Replacement ! 468: .LP ! 469: The following commands allow the user to simultaneously delete and ! 470: insert new text. All such actions can be \fBundone\fR by typing ! 471: \fBu\fR following the command. ! 472: .VL 16 ! 473: .IP "r<chr>" 16 ! 474: Replaces the character at the current cursor position with <chr>. This ! 475: is a one character replacement. No <esc> is required for termination. ! 476: Mnemonic: \fBr\fReplace character ! 477: .IP "R{text}<esc>" 16 ! 478: Starts overlaying the characters on the screen with whatever you type. ! 479: It does not stop until an <esc> is typed. ! 480: .IP "[cnt]s{text}<esc>" 16 ! 481: Substitute for "cnt" characters beginning at the current cursor ! 482: position. A "$" will appear at the position in the text where the ! 483: "cnt"'th character appears so you will know how much you are erasing. ! 484: Mnemonic: \fBs\fRubstitute ! 485: .IP "[cnt]S{text}<esc>" 16 ! 486: Substitute for the entire current line (or lines). If no count is given, ! 487: a "$" appears at the end of the current line. If a count of more than ! 488: 1 is given, all the lines to be replaced are deleted before the insertion ! 489: begins. ! 490: .IP "[cnt]c{motion}{text}<esc>" 16 ! 491: .br ! 492: Change the specified "motion" by replacing it with the ! 493: insertion text. A "$" will appear at the end of the last item ! 494: that is being deleted unless the deletion involves whole lines. ! 495: Motion's can be any motion from sections 4.1 or 4.2. ! 496: Stuttering the c (e.g. [cnt]cc) changes cnt lines. ! 497: .LE ! 498: .NH 2 ! 499: Moving Text ! 500: .LP ! 501: \fBVi\fR provides a number of ways of moving chunks of text around. ! 502: There are nine buffers into which each piece of text which is deleted ! 503: or "yanked" is put in addition to the "undo" buffer. ! 504: The most recent deletion or yank is in the "undo" buffer and also ! 505: usually in buffer ! 506: 1, the next most recent in buffer 2, and so forth. Each new deletion ! 507: pushes down all the older deletions. Deletions older than 9 ! 508: disappear. There is also ! 509: a set of named registers, a-z, into which text can optionally ! 510: be placed. If any delete or replacement type command is preceded ! 511: by \fB"<a-z>\fR, that named buffer will contain the text deleted ! 512: after the command is executed. For example, \fB"a3dd\fR will delete ! 513: three lines starting at the current line and put them in buffer \fB"a\fR.* ! 514: .FS ! 515: * Referring to an upper case letter as a buffer name (A-Z) is the ! 516: same as referring to the lower case letter, except that text placed ! 517: in such a buffer is appended to it instead of replacing it. ! 518: .FE ! 519: There are two more basic commands and ! 520: some variations useful in getting and putting text into a file. ! 521: .VL 16 ! 522: .IP ["<a-z>][cnt]y{motion} 16 ! 523: .sp 1 ! 524: Yank the specified item or "cnt" items and put in the "undo" buffer or ! 525: the specified buffer. The variety of "items" that can be yanked ! 526: is the same as those that can be deleted with the "d" command or ! 527: changed with the "c" command. In the same way that "dd" means ! 528: delete the current line and "cc" means replace the current line, ! 529: "yy" means yank the current line. ! 530: .IP ["<a-z>][cnt]Y 16 ! 531: Yank the current line or the "cnt" lines starting from the current ! 532: line. If no buffer is specified, they will go into the "undo" buffer, ! 533: like any delete would. It is equivalent to "yy". ! 534: Mnemonic: \fBY\fRank ! 535: .IP ["<a-z>]p 16 ! 536: Put "undo" buffer or the specified buffer down \fBafter\fR the cursor. ! 537: If whole lines were yanked or deleted into the buffer, then they will be ! 538: put down on the line following the line the cursor is on. If ! 539: something else was deleted, like a word or sentence, then it will ! 540: be inserted immediately following the cursor. ! 541: Mnemonic: \fBp\fRut buffer ! 542: .IP ! 543: It should be noted that text in the named buffers remains there when you ! 544: start editing a new file with the \fB:e file<esc>\fR command. Since ! 545: this is so, it is possible to copy or delete text from one file and ! 546: carry it over to another file in the buffers. ! 547: However, the undo buffer and the ability to undo are lost when ! 548: changing files. ! 549: .IP ["<a-z>]P 16 ! 550: Put "undo" buffer or the specified buffer down \fBbefore\fR the cursor. ! 551: If whole lines where yanked or deleted into the buffer, then they will be ! 552: put down on the line preceding the line the cursor is on. If ! 553: something else was deleted, like a word or sentence, then it will ! 554: be inserted immediately preceding the cursor. ! 555: .IP [cnt]>{motion} 16 ! 556: The shift operator will right shift all the text from the line on which ! 557: the cursor is located to the line where the \fBmotion\fR is located. ! 558: The text is shifted by one \fBshiftwidth\fR. (See section 6.) ! 559: \fB>>\fR means right shift the current line or lines. ! 560: .IP [cnt]<{motion} 16 ! 561: The shift operator will left shift all the text from the line on which ! 562: the cursor is located to the line where the \fBitem\fR is located. ! 563: The text is shifted by one \fBshiftwidth\fR. (See section 6.) ! 564: \fB<<\fR means left shift the current line or lines. ! 565: Once the line has reached the left margin it is not further affected. ! 566: .IP [cnt]={motion} 16 ! 567: Prettyprints the indicated area according to ! 568: .B lisp ! 569: conventions. ! 570: The area should be a lisp s-expression. ! 571: .LE ! 572: .NH 2 ! 573: Miscellaneous Commands ! 574: .LP ! 575: \fBVi\fR has a number of miscellaneous commands that are very ! 576: useful. They are: ! 577: .VL 16 ! 578: .IP ZZ 16 ! 579: This is the normal way to exit from vi. ! 580: If any changes have been made, the file is written out. ! 581: Then you are returned to the shell. ! 582: .IP ^L 16 ! 583: Redraw the current screen. This is useful if someone "write"s you ! 584: while you are in "vi" or if for any reason garbage gets onto the ! 585: screen. ! 586: .IP ^R 16 ! 587: On dumb terminals, those not having the "delete line" function ! 588: (the vt100 is such a terminal), \fBvi\fR saves redrawing the ! 589: screen when you delete a line by just marking the line with an ! 590: "@" at the beginning and blanking the line. If you want to ! 591: actually get rid of the lines marked with "@" and see what the ! 592: page looks like, typing a ^R will do this. ! 593: .IP \s+4.\s0 16 ! 594: "Dot" is a particularly useful command. It repeats the last ! 595: text modifying command. Therefore you can type a command once and ! 596: then to another place and repeat it by just typing ".". ! 597: .IP u 16 ! 598: Perhaps the most important command in the editor, ! 599: u undoes the last command that changed the buffer. ! 600: Mnemonic: \fBu\fRndo ! 601: .IP U 16 ! 602: Undo all the text modifying commands performed on the current line ! 603: since the last time you moved onto it. ! 604: .IP [cnt]J 16 ! 605: Join the current line and the following line. The <nl> is deleted ! 606: and the two lines joined, usually with a space between the ! 607: end of the first line and the beginning of what was the second ! 608: line. If the first line ended with a "period", then two spaces ! 609: are inserted. ! 610: A count joins the next cnt lines. ! 611: Mnemonic: \fBJ\fRoin lines ! 612: .IP Q 16 ! 613: Switch to \fBex\fR editing mode. ! 614: In this mode \fBvi\fR will behave very much like \fBed\fR. ! 615: The editor in this mode will operate on single lines normally and ! 616: will not attempt to keep the "window" up to date. ! 617: Once in this mode it is also possible to switch to the \fBopen\fR ! 618: mode of editing. By entering the command \fB[line number]open<nl>\fR ! 619: you enter this mode. It is similar to the normal visual mode ! 620: except the window is only \fBone\fR line long. ! 621: Mnemonic: \fBQ\fRuit visual mode ! 622: .IP ^] 16 ! 623: An abbreviation for a tag command. ! 624: The cursor should be positioned at the beginning of a word. ! 625: That word is taken as a tag name, and the tag with that ! 626: name is found as if it had been typed in a :tag command. ! 627: .IP [cnt]!{motion}{UNIX\ cmd}<nl> 16 ! 628: .br ! 629: Any UNIX filter ! 630: (e.g. command that reads the standard input and outputs something ! 631: to the standard output) can be sent a section of the current file and ! 632: have the output of the command replace the original text. Useful ! 633: examples are programs like \fBcb\fR, \fBsort\fR, and ! 634: \fBnroff\fR. For instance, using \fBsort\fR it would be possible to ! 635: sort a section of the current file into a new list. ! 636: Using \fB!!\fR means take a line or lines starting at the line the ! 637: cursor is currently on and pass them to the UNIX command. ! 638: .B NOTE: ! 639: To just escape to the shell for one command, ! 640: use :!{cmd}<nl>, see section 5. ! 641: .IP z{cnt}<nl> 16 ! 642: This resets the current window size to "cnt" lines and redraws the screen. ! 643: .LE ! 644: .NH 2 ! 645: Special Insert Characters ! 646: .LP ! 647: There are some characters that have special meanings during ! 648: insert modes. They are: ! 649: .VL 16 ! 650: .IP ^V 16 ! 651: During inserts, typing a ^V allows you to quote control characters ! 652: into the file. Any character typed after the ^V will be inserted ! 653: into the file. ! 654: .IP [^]^D\ or\ [0]^D 16 ! 655: <^D> without any argument backs up one \fBshiftwidth\fR. This is necessary ! 656: to remove indentation that was inserted by the \fBautoindent\fR feature. ! 657: ^<^D> temporarily removes all the autoindentation, thus placing the cursor ! 658: at the left margin. On the next line, the previous indent level will be ! 659: restored. This is useful for putting "labels" at the left margin. ! 660: 0<^D> says remove all autoindents and stay that way. Thus the cursor ! 661: moves to the left margin and stays there on successive lines until ! 662: <tab>'s are typed. As with the <tab>, the <^D> is only effective before ! 663: any other "non-autoindent" controlling characters are typed. ! 664: Mnemonic: \fBD\fRelete a shiftwidth ! 665: .IP ^W 16 ! 666: If the cursor is sitting on a word, <^W> moves the cursor back to the beginning ! 667: of the word, thus erasing the word from the insert. ! 668: Mnemonic: erase \fBW\fRord ! 669: .IP <bs> 16 ! 670: The backspace always serves as an erase during insert modes in addition ! 671: to your normal "erase" character. To insert a <bs> into your file, use ! 672: the <^V> to quote it. ! 673: .LE ! 674: .NH 1 ! 675: \fB:\fR Commands ! 676: .LP ! 677: Typing a ":" during command mode causes \fBvi\fR to put the cursor at ! 678: the bottom on the screen in preparation for a command. In the ! 679: ":" mode, \fBvi\fR can be given most \fBed\fR commands. It is ! 680: also from this mode that you exit from \fBvi\fR or switch to different ! 681: files. All commands of this variety are terminated by a <nl>, <cr>, ! 682: or <esc>. ! 683: .VL 16 ! 684: .IP ":w[!] [file]" 16 ! 685: Causes \fBvi\fR to write out the current text to the disk. It is ! 686: written to the file you are editing unless "file" is supplied. If ! 687: "file" is supplied, the write is directed to that file instead. If ! 688: that file already exists, \fBvi\fR will not perform the write unless ! 689: the "!" is supplied indicating you ! 690: .I really ! 691: want to destroy the older copy of the file. ! 692: .IP :q[!] 16 ! 693: Causes \fBvi\fR to exit. If you have modified the file you are ! 694: looking at currently and haven't written it out, \fBvi\fR will ! 695: refuse to exit unless the "!" is supplied. ! 696: .IP ":e[!] [+[cmd]] [file]" 16 ! 697: .sp 1 ! 698: Start editing a new file called "file" or start editing the current ! 699: file over again. The command ":e!" says "ignore the changes I've made ! 700: to this file and start over from the beginning". It is useful if ! 701: you really mess up the file. The optional "+" says instead of starting ! 702: at the beginning, start at the "end", or, ! 703: if "cmd" is supplied, execute "cmd" first. ! 704: Useful cases of this are where cmd is "n" (any integer) which starts ! 705: at line number n, ! 706: and "/text", which searches for "text" and starts at the line where ! 707: it is found. ! 708: .IP "^^" 16 ! 709: Switch back to the place you were before your last tag command. ! 710: If your last tag command stayed within the file, ^^ returns to that tag. ! 711: If you have no recent tag command, it will return to the ! 712: same place in the previous file that it was showing when you switched ! 713: to the current file. ! 714: .IP ":n[!]" 16 ! 715: Start editing the next file in the argument list. Since \fBvi\fR ! 716: can be called with multiple file names, the ":n" command tells it to ! 717: stop work on the current file and switch to the next file. If the ! 718: current file was modifies, it has to be written out before the ":n" ! 719: will work or else the "!" must be supplied, which says discard the ! 720: changes I made to the current file. ! 721: .IP ":n[!] file [file file ...]" 16 ! 722: .sp ! 723: Replace the current argument list with a new list of files and start ! 724: editing the first file in this new list. ! 725: .IP ":r file" 16 ! 726: Read in a copy of "file" on the line after the cursor. ! 727: .IP ":r !cmd" 16 ! 728: Execute the "cmd" and take its output and put it into the file after ! 729: the current line. ! 730: .IP ":!cmd" 16 ! 731: Execute any UNIX shell command. ! 732: .IP ":ta[!] tag" 16 ! 733: .B Vi ! 734: looks in the file named ! 735: .B tags ! 736: in the current directory. ! 737: .B Tags ! 738: is a file of lines in the format: ! 739: .sp 1 ! 740: .ti +8 ! 741: tag filename \fBvi\fR-search-command ! 742: .sp 1 ! 743: If \fBvi\fR finds the tag you specified in the \fB:ta\fR command, ! 744: it stops editing the current file if necessary and if the current file is ! 745: up to date on the disk and switches to the file specified and uses the ! 746: search pattern specified to find the "tagged" item of interest. This ! 747: is particularly useful when editing multi-file C programs such as the ! 748: operating system. There is a program called \fBctags\fR which will ! 749: generate an appropriate \fBtags\fR file for C and f77 ! 750: programs so that by saying ! 751: \fB:ta function<nl>\fR you will be switched to that function. ! 752: It could also be useful when editing multi-file documents, though the ! 753: \fBtags\fR file would have to be generated manually. ! 754: .LE ! 755: .NH 1 ! 756: Special Arrangements for Startup ! 757: .PP ! 758: \fBVi\fR takes the value of \fB$TERM\fR and looks up the characteristics ! 759: of that terminal in the file \fB/etc/termcap\fR. ! 760: If you don't know \fBvi\fR's name for the terminal you are working ! 761: on, look in \fB/etc/termcap\fR. ! 762: .PP ! 763: When \fBvi\fR starts, it attempts to read the variable EXINIT ! 764: from your environment.* ! 765: If that exists, it takes the values in it as the default values ! 766: for certain of its internal constants. See the section on "Set Values" ! 767: for further details. ! 768: If EXINIT doesn't exist you will get all the normal defaults. ! 769: .FS ! 770: * On version 6 systems ! 771: Instead of EXINIT, put the startup commands in the file .exrc ! 772: in your home directory. ! 773: .FE ! 774: .PP ! 775: Should you inadvertently hang up the phone while inside ! 776: .B vi , ! 777: or should the computer crash, ! 778: all may not be lost. ! 779: Upon returning to the system, type: ! 780: .DS ! 781: vi \-r file ! 782: .DE ! 783: This will normally recover the file. If there is more than one ! 784: temporary file for a specific file name, \fBvi\fR recovers the ! 785: newest one. You can get an older version by recovering the ! 786: file more than once. ! 787: The command "vi -r" without a file name gives you the list of files ! 788: that were saved in the last system crash ! 789: (but ! 790: .I not ! 791: the file just saved when the phone was hung up). ! 792: .NH 1 ! 793: Set Commands ! 794: .LP ! 795: \fBVi\fR has a number of internal variables and switches which can be ! 796: set to achieve special affects. ! 797: These options come in three forms, those that are switches, which toggle ! 798: from off to on and back, those that require a numeric value, and those ! 799: that require an alphanumeric string value. ! 800: The toggle options are set by a command of the form: ! 801: .DS ! 802: :set option<nl> ! 803: .DE ! 804: and turned off with the command: ! 805: .DS ! 806: :set nooption<nl> ! 807: .DE ! 808: Commands requiring a value are set with a command of the form: ! 809: .DS ! 810: :set option=value<nl> ! 811: .DE ! 812: To display the value of a specific option type: ! 813: .DS ! 814: :set option?<nl> ! 815: .DE ! 816: To display only those that you have changed type: ! 817: .DS ! 818: :set<nl> ! 819: .DE ! 820: and to display the long table of all the settable parameters and ! 821: their current values type: ! 822: .DS ! 823: :set all<nl> ! 824: .DE ! 825: .PP ! 826: Most of the options have a long form and an abbreviation. Both are ! 827: listed in the following table as well as the normal default value. ! 828: .PP ! 829: To arrange to have values other than the default used every time you ! 830: enter ! 831: .B vi , ! 832: place the appropriate ! 833: .B set ! 834: command in EXINIT in your environment, e.g. ! 835: .DS ! 836: EXINIT='set ai aw terse sh=/bin/csh' ! 837: export EXINIT ! 838: .DE ! 839: or ! 840: .DS ! 841: setenv EXINIT 'set ai aw terse sh=/bin/csh' ! 842: .DE ! 843: for ! 844: .B sh ! 845: and ! 846: .B csh , ! 847: respectively. ! 848: These are usually placed in your .profile or .login. ! 849: If you are running a system without environments (such as version 6) ! 850: you can place the set command in the file .exrc in your home ! 851: directory. ! 852: .VL 16 ! 853: .IP autoindent\ ai 16 ! 854: Default: noai Type: toggle ! 855: .br ! 856: When in autoindent mode, vi helps you indent code by starting each ! 857: line in the same column as the preceding line. ! 858: Tabbing to the right with <tab> or <^T> will move this boundary to ! 859: the right, and it can be moved to the left with <^D>. ! 860: .IP autoprint\ ap 16 ! 861: Default: ap Type: toggle ! 862: .br ! 863: Causes the current line to be printed after each ex text modifying command. ! 864: This is not of much interest in the normal \fBvi\fR visual mode. ! 865: .IP autowrite\ aw 16 ! 866: Default: noaw type: toggle ! 867: .br ! 868: Autowrite causes an automatic write to be done if there are unsaved ! 869: changes before certain commands which change files or otherwise ! 870: interact with the outside world. ! 871: These commands are :!, :tag, :next, :rewind, ^^, and ^]. ! 872: .IP beautify\ bf 16 ! 873: Default: nobf Type: toggle ! 874: .br ! 875: Causes all control characters except <tab>, <nl>, and <ff> to be discarded. ! 876: .IP directory\ dir 16 ! 877: Default: dir=/tmp Type: string ! 878: .br ! 879: This is the directory in which \fBvi\fR puts its temporary file. ! 880: .IP errorbells\ eb 16 ! 881: Default: noeb Type: toggle ! 882: .br ! 883: Error messages are preceded by a <bell>. ! 884: .IP hardtabs\ ht 16 ! 885: Default: hardtabs=8 Type: numeric ! 886: .br ! 887: This option contains the value of hardware tabs in your terminal, or ! 888: of software tabs expanded by the Unix system. ! 889: .IP ignorecase\ ic 16 ! 890: Default: noic Type: toggle ! 891: .br ! 892: All upper case characters are mapped to lower case in regular expression ! 893: matching. ! 894: .IP lisp 16 ! 895: Default: nolisp Type: toggle ! 896: .br ! 897: Autoindent for \fBlisp\fR code. The commands \fB( ) [[\fR and \fB]]\fR ! 898: are modified appropriately to affect s-expressions and functions. ! 899: .IP list 16 ! 900: Default: nolist Type: toggle ! 901: .br ! 902: All printed lines have the <tab> and <nl> characters displayed visually. ! 903: .IP magic 16 ! 904: Default: magic Type: toggle ! 905: .br ! 906: Enable the metacharacters for matching. These include \fB. * < > [string] ! 907: [^string]\fR and \fB[<chr>-<chr>]\fR. ! 908: .IP number\ nu 16 ! 909: Default: nonu Type: toggle ! 910: .br ! 911: Each line is displayed with its line number. ! 912: .IP open 16 ! 913: Default: open Type: toggle ! 914: .br ! 915: When set, prevents entering open or visual modes from ex or edit. ! 916: Not of interest from vi. ! 917: .IP optimize\ opt 16 ! 918: Default: opt Type: toggle ! 919: .br ! 920: Basically of use only when using the \fBex\fR capabilities. This ! 921: option prevents automatic <cr>s from taking place, ! 922: and speeds up output of indented lines, ! 923: at the expense of losing typeahead on some versions of UNIX. ! 924: .IP paragraphs\ para 16 ! 925: Default: para=IPLPPPQPP\ bp Type: string ! 926: .br ! 927: Each pair of characters in the string indicate \fBnroff\fR macros ! 928: which are to be treated as the beginning of a paragraph for the ! 929: \fB{\fR and \fB}\fR commands. The default string is for the \fB-ms\fR ! 930: and \fB-mm\fR macros. ! 931: To indicate one letter \fBnroff\fR macros, such as \fB.P\fR or \fB.H\fR, ! 932: quote a space in for the second character position. For example: ! 933: .sp 1 ! 934: .ti +8 ! 935: :set paragraphs=P\e bp<nl> ! 936: .sp 1 ! 937: would cause \fBvi\fR to consider \fB.P\fR and \fB.bp\fR as paragraph ! 938: delimiters. ! 939: .IP prompt 16 ! 940: Default: prompt Type: toggle ! 941: .br ! 942: In ! 943: .B ex ! 944: command mode the prompt character \fB:\fR will be printed when ! 945: \fBex\fR is waiting for a command. This is not of interest from vi. ! 946: .IP redraw 16 ! 947: Default: noredraw Type: toggle ! 948: .br ! 949: On dumb terminals, force the screen to always be up to date, ! 950: by sending great amounts of output. Useful only at high speeds. ! 951: .IP report 16 ! 952: Default: report=5 Type: numeric ! 953: .br ! 954: This sets the threshold for the number of lines modified. When ! 955: more than this number of lines are modified, removed, or yanked, ! 956: \fBvi\fR will report the number of lines changed at the bottom of ! 957: the screen. ! 958: .IP scroll 16 ! 959: Default: scroll={1/2 window} Type: numeric ! 960: .br ! 961: This is the number of lines that the screen scrolls up or down when ! 962: using the <^U> and <^D> commands. ! 963: .IP sections 16 ! 964: Default: sections=SHNHH HU Type: string ! 965: .br ! 966: Each two character pair of this string specify \fBnroff\fR macro names ! 967: which are to be treated as the beginning of a section by the ! 968: \fB]]\fR and \fB[[\fR commands. The default string is for the \fB-ms\fR ! 969: and \fB-mm\fR macros. ! 970: To enter one letter \fBnroff\fR macros, use a quoted space as the ! 971: second character. ! 972: See \fBparagraphs\fR for a fuller explanation. ! 973: .IP shell\ sh 16 ! 974: Default: sh=from environment SHELL or /bin/sh Type: string ! 975: .br ! 976: This is the name of the \fBsh\fR to be used for "escaped" commands. ! 977: .IP shiftwidth\ sw 16 ! 978: Default: sw=8 Type: numeric ! 979: .br ! 980: This is the number of spaces that a <^T> or <^D> will move over for ! 981: indenting, and the amount < and > shift by. ! 982: .IP showmatch\ sm 16 ! 983: Default: nosm Type: toggle ! 984: .br ! 985: When a \fB)\fR or \fB}\fR is typed, show the matching \fB(\fR or \fB{\fR ! 986: by moving the cursor to it for one second if it is on the current screen. ! 987: .IP slowopen\ slow 16 ! 988: Default: terminal dependent Type: toggle ! 989: .br ! 990: On terminals that are slow and unintelligent, this option prevents the ! 991: updating of the screen some of the time to improve speed. ! 992: .IP tabstop\ ts 16 ! 993: Default: ts=8 Type: numeric ! 994: .br ! 995: <tab>s are expanded to boundaries that are multiples of this value. ! 996: .IP taglength\ tl 16 ! 997: Default: tl=0 Type: numeric ! 998: .br ! 999: If nonzero, tag names are only significant to this many characters. ! 1000: .IP term 16 ! 1001: Default: (from environment \fBTERM\fP, else dumb) Type: string ! 1002: .br ! 1003: This is the terminal and controls the visual displays. It cannot be ! 1004: changed when in "visual" mode, ! 1005: you have to Q to command mode, type a ! 1006: set term command, and do ``vi.'' to get back into visual. ! 1007: Or exit vi, fix $TERM, and reenter. ! 1008: The definitions that drive a particular ! 1009: terminal type are found in the file \fB/etc/termcap\fR. ! 1010: .IP terse 16 ! 1011: Default: terse Type: toggle ! 1012: .br ! 1013: When set, the error diagnostics are short. ! 1014: .IP warn 16 ! 1015: Default: warn Type: toggle ! 1016: .br ! 1017: The user is warned if she/he tries to escape to ! 1018: the shell without writing out the current changes. ! 1019: .IP window 16 ! 1020: Default: window={8 at 600 baud or less, 16 at 1200 baud, and screen ! 1021: size \- 1 at 2400 baud or more} Type: numeric ! 1022: .br ! 1023: This is the number of lines in the window whenever \fBvi\fR must redraw ! 1024: an entire screen. It is useful to make this size smaller if you are ! 1025: on a slow line. ! 1026: .IP w300,\ w1200,\ w9600 ! 1027: .br ! 1028: These set window, but only within the corresponding speed ranges. ! 1029: They are useful in an EXINIT to fine tune window sizes. ! 1030: For example, ! 1031: .DS ! 1032: set w300=4 w1200=12 ! 1033: .DE ! 1034: causes a 4 lines window at speed up to 600 baud, a 12 line window at 1200 ! 1035: baud, and a full screen (the default) at over 1200 baud. ! 1036: .IP wrapscan\ ws 16 ! 1037: Default: ws Type: toggle ! 1038: .br ! 1039: Searches will wrap around the end of the file when is option is set. When ! 1040: it is off, the search will terminate when it reaches the end or the ! 1041: beginning of the file. ! 1042: .IP wrapmargin\ wm 16 ! 1043: Default: wm=0 Type: numeric ! 1044: .br ! 1045: \fBVi\fR will automatically insert a <nl> when it finds a natural ! 1046: break point (usually a <sp> between words) that occurs within ! 1047: "wm" spaces of the right margin. ! 1048: Therefore with "wm=0" the option is off. Setting it to 10 would ! 1049: mean that any time you are within 10 spaces of the right margin ! 1050: \fBvi\fR would be looking for a <sp> or <tab> which it could ! 1051: replace with a <nl>. This is convenient for people who forget ! 1052: to look at the screen while they type. ! 1053: (In version 3, wrapmargin behaves more like nroff, in that the ! 1054: boundary specified by the distance from the right edge of the screen ! 1055: is taken as the rightmost edge of the area where a break is allowed, ! 1056: instead of the leftmost edge.) ! 1057: .IP writeany\ wa 16 ! 1058: Default: nowa Type: toggle ! 1059: .br ! 1060: \fBVi\fR normally makes a number of checks before it writes out a file. ! 1061: This prevents the user from inadvertently destroying a file. When the ! 1062: "writeany" option is enabled, \fBvi\fR no longer makes these checks. ! 1063: .LE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.