1 .\" Copyright (c) 1980, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)vi.apwh.ms 8.2 (Berkeley) 8/18/96
33 Vi Command & Function Reference
37 Revised for version 2.12 by Mark Horton
42 This document does not claim to be 100% complete. There are a
43 few commands listed in the original document that I was unable
44 to test either because I do not speak \fBlisp\fR, because they
45 required programs we don't have, or because I wasn't able to make
46 them work. In these cases I left the command out. The commands
47 listed in this document have been tried and are known to work.
48 It is expected that prospective users of this document will read
49 it once to get the flavor of everything that \fBvi\fR can do
50 and then use it as a reference document. Experimentation is
51 recommended. If you don't understand a command, try it and
54 [Note: In revising this document, I have attempted to make it
55 completely reflect version 2.12 of
57 It does not attempt to document the VAX version (version 3),
58 but with one or two exceptions (wrapmargin, arrow keys)
59 everything said about 2.12 should apply to 3.1.
64 \fB[option]\fR is used to denote optional parts of a command.
65 Many \fBvi\fR commands have an optional count. \fB[cnt]\fR
66 means that an optional number may precede the command to
67 multiply or iterate the command.
68 \fB{variable item}\fR is used to denote parts of the command
69 which must appear, but can take a number of different values.
70 \fB<character [-character]>\fR means that the character or
71 one of the characters in the range described between the
72 two angle brackets is to be typed.
73 For example \fB<esc>\fR means
74 the \fBescape\fR key is to be typed. \fB<a-z>\fR means that a
75 lower case letter is to be typed. \fB^<character>\fR means that
76 the character is to be typed as a \fBcontrol\fR character, that is,
77 with the \fB<cntl>\fR key held down while simultaneously typing
78 the specified character. In this document control characters will
79 be denoted using the \fIupper case\fR character, but
80 ^<uppercase chr> and ^<lowercase chr> are equivalent. That is, for
81 example, \fB<^D>\fR is equal to \fB<^d>\fR.
82 The most common character abbreviations
83 used in this list are as follows:
88 carriage return, ^M, octal 015
90 linefeed ^J, octal 012
92 newline, ^J, octal 012 (same as linefeed)
94 backspace, ^H, octal 010
100 formfeed, ^L, octal 014
110 To run \fBvi\fR the shell variable \fBTERM\fR must be defined and
111 exported to your environment.
112 How you do this depends on which shell you are using.
113 You can tell which shell you have by the character it
114 prompts you for commands with.
115 The Bourne shell prompts with `$', and the C shell prompts with `%'.
116 For these examples, we will suppose
117 that you are using an HP 2621 terminal, whose termcap name is ``2621''.
121 To manually set your terminal type to 2621 you would type:
127 There are various ways of having this automatically or
128 semi-automatically done when you log in.
129 Suppose you usually dial in on a 2621.
130 You want to tell this to the machine, but still have it
131 work when you use a hardwired terminal.
132 The recommended way, if you have the
134 program, is to use the sequence
136 tset \-s \-d 2621 > tset$$
140 in your .login (for csh) or the same thing using `.' instead of `source'
141 in your .profile (for sh).
142 The above line says that if you are dialing in you are on a 2621,
143 but if you are on a hardwired terminal it figures out your terminal
144 type from an on-line list.
148 To manually set your terminal type to 2621 you would type:
153 There are various ways of having this automatically or
154 semi-automatically done when you log in.
155 Suppose you usually dial in on a 2621.
156 You want to tell this to the machine, but still have it
157 work when you use a hardwired terminal.
158 The recommended way, if you have the
160 program, is to use the sequence
162 tset \-s \-d 2621 > tset$$
168 * On a version 6 system
169 without environments, the invocation of tset
170 is simpler, just add the line ``tset \-d 2621''
171 to your .login or .profile.
173 The above line says that if you are dialing in you are on a 2621,
174 but if you are on a hardwired terminal it figures out your terminal
175 type from an on-line list.
179 \fBVi\fR is a visual editor with a window on the file. What
180 you see on the screen is \fBvi\fR's current notion of
181 what your file will contain,
182 (at this point in the file),
183 when it is written out.
184 Most commands do not cause any change in the screen until the
185 complete command is typed. Should you get confused while
186 typing a command, you can abort the command by typing an
187 <del> character. You will know you are back to command level
188 when you hear a <bell>. Usually typing an <esc> will produce the
189 same result. When \fBvi\fR gets an improperly formatted command
191 Following are the \fBvi\fR commands broken down by function.
203 The file will be read in and the cursor will be placed at the beginning
205 The first screenfull of the file will be displayed on the terminal.
207 To get out of the editor, type
211 If you are in some special mode, such as input mode
212 or the middle of a multi-keystroke command, it may
213 be necessary to type <esc> first.
215 Cursor and Page Motion
219 The arrow keys (see the next four commands)
220 on certain kinds of terminals will not work with the
221 PDP-11 version of vi. The control versions or the hjkl versions will
222 work on any terminal. Experienced users prefer the hjkl keys because
223 they are always right under their fingers. Beginners often prefer
224 the arrow keys, since they do not require memorization of which hjkl
226 The mnemonic value of hjkl is clear from looking at the keyboard of an adm3a.
228 .IP "[cnt]<bs> or [cnt]h or [cnt]\(<-" 16
230 Move the cursor to the left one character. Cursor stops at the left
232 If cnt is given, these commands move that many spaces.
233 .IP "[cnt]^N or [cnt]j or [cnt]\(da or [cnt]<lf>" 16
236 Moving off the screen scrolls the window to force a new line
239 .IP "[cnt]^P or [cnt]k or [cnt]\(ua" 16
242 Moving off the top of the screen forces new text onto the screen.
243 Mnemonic: \fBP\fRrevious
244 .IP "[cnt]<sp> or [cnt]l or [cnt]\(->" 16
246 Move to the right one character.
247 Cursor will not go beyond the end of the line.
249 Move the cursor up the screen to the beginning of the next line.
251 .IP "[cnt]+ or [cnt]<cr>" 16
253 Move the cursor down the screen to the beginning of the next line.
254 Scroll up if necessary.
256 Move the cursor to the end of the line.
257 If there is a count, move to the end of the line "cnt" lines
260 Move the cursor to the beginning of the first word on the line.
262 Move the cursor to the left margin of the current line.
264 Move the cursor to the column specified by the count. The default is
267 Move the cursor to the beginning of the next word. If there
268 is a count, then move forward that many words and
269 position the cursor at the beginning of the word.
270 Mnemonic: next-\fBw\fRord
272 Move the cursor to the beginning of the next word which follows
273 a "white space" (<sp>,<tab>, or <nl>). Ignore other punctuation.
275 Move the cursor to the preceding word. Mnemonic: \fBb\fRackup-word
277 Move the cursor to the preceding word that is separated from the
278 current word by a "white space" (<sp>,<tab>, or <nl>).
280 Move the cursor to the end of the current word or the end of the
281 "cnt"'th word hence. Mnemonic: \fBe\fRnd-of-word
283 Move the cursor to the end of the current word which is delimited by
284 "white space" (<sp>,<tab>, or <nl>).
285 .IP "[line number]G" 16
287 Move the cursor to the line specified. Of particular use are the
288 sequences "1G" and "G", which move the cursor to the beginning and
289 the end of the file respectively. Mnemonic: \fBG\fRo-to
292 The next four commands (^D, ^U, ^F, ^B)
293 are not true motion commands, in that they
294 cannot be used as the object of commands such as delete or change.
296 Move the cursor down in the file by "cnt" lines (or the last "cnt"
297 if a new count isn't given. The initial default is half a page.) The
298 screen is simultaneously scrolled up. Mnemonic: \fBD\fRown
300 Move the cursor up in the file by "cnt" lines. The screen is simultaneously
301 scrolled down. Mnemonic: \fBU\fRp
303 Move the cursor to the next page. A count moves that many pages.
304 Two lines of the previous page are kept on the screen for continuity if
305 possible. Mnemonic: \fBF\fRorward-a-page
307 Move the cursor to the previous page. Two lines of the current page
308 are kept if possible. Mnemonic: \fBB\fRackup-a-page
310 Move the cursor to the beginning of the next sentence.
311 A sentence is defined as ending with a ".", "!", or "?"
312 followed by two spaces or a <nl>.
314 Move the cursor backwards to the beginning of a sentence.
316 Move the cursor to the beginning of the next paragraph. This command
317 works best inside \fBnroff\fR documents. It understands two sets of
318 \fBnroff\fR macros, \fB\-ms\fR and \fB\-mm\fR, for which the
319 commands ".IP", ".LP", ".PP", ".QP", "P", as well as the nroff command ".bp"
320 are considered to be paragraph delimiters.
321 A blank line also delimits a paragraph.
322 The \fBnroff\fR macros that it accepts as paragraph delimiters is
323 adjustable. See \fBparagraphs\fR under the \fBSet Commands\fR section.
325 Move the cursor backwards to the beginning of a paragraph.
327 Move the cursor to the next "section", where a section is defined by
328 two sets of \fBnroff\fR macros, \fB\-ms\fR and \fB\-mm\fR, in which
329 ".NH", ".SH", and ".H" delimit a section. A line beginning with a <ff><nl>
330 sequence, or a line beginning with a "{" are also considered to
331 be section delimiters. The last option makes it
332 useful for finding the beginnings of C functions.
333 The \fBnroff\fR macros that are used for section delimiters can be adjusted.
334 See \fBsections\fR under the \fBSet Commands\fR section.
336 Move the cursor backwards to the beginning of a section.
338 Move the cursor to the matching parenthesis
339 or brace. This is very useful in C or lisp code. If the
340 cursor is sitting on a \fB( ) {\fR or \fB}\fR the cursor
341 is moved to the matching character at the other end of the
342 section. If the cursor is not sitting on a brace or a
343 parenthesis, \fBvi\fR searches forward until it finds one
344 and then jumps to the match mate.
346 If there is no count move the cursor to the top left position on the screen.
347 If there is a count, then move the cursor to the beginning of the line
348 "cnt" lines from the top of the screen. Mnemonic: \fBH\fRome
350 If there is no count move the cursor to the beginning
351 of the last line on the screen.
352 If there is a count, then move the cursor to the beginning of the line
353 "cnt" lines from the bottom of the screen. Mnemonic: \fBL\fRast
355 Move the cursor to the beginning of the middle line on the screen.
356 Mnemonic: \fBM\fRiddle
358 This command does not move the cursor, but it \fBmarks\fR the place
359 in the file and the character "<a-z>" becomes the label for referring
360 to this location in the file. See the next two commands. Mnemonic:
363 The mark command is not a motion, and cannot be used as the target
364 of commands such as delete.
366 Move the cursor to the beginning of the line that is marked with the label
369 Move the cursor to the exact position on the line that was marked with
370 with the label "<a-z>".
372 Move the cursor back to the beginning of the line where it was before the
373 last "non-relative" move. A "non-relative" move is something such as a
374 search or a jump to a specific line in the file, rather than moving the
375 cursor or scrolling the screen.
377 Move the cursor back to the exact spot on the line where it was located
378 before the last "non-relative" move.
383 The following commands allow you to search for items in a file.
387 Search forward on the line for the next or "cnt"'th occurrence of
388 the character "chr". The cursor is placed \fBat\fR the character
389 of interest. Mnemonic: \fBf\fRind character
392 Search backwards on the line for the next or "cnt"'th occurrence of
393 the character "chr". The cursor is placed \fBat\fR the character
397 Search forward on the line for the next or "cnt"'th occurrence of
398 the character "chr". The cursor is placed \fBjust preceding\fR
399 the character of interest. Mnemonic: move cursor up \fBt\fRo character
402 Search backwards on the line for the next or "cnt"'th occurrence of
403 the character "chr". The cursor is placed \fBjust preceding\fR
404 the character of interest.
406 Repeat the last "f", "F", "t" or "T" command.
408 Repeat the last "f", "F", "t" or "T" command, but in the opposite
409 search direction. This is useful if you overshoot.
410 .IP "[cnt]/[string]/<nl>" 16
412 Search forward for the next occurrence of "string".
413 Wrap around at the end of the file
415 The final \fB</>\fR is not required.
416 .IP "[cnt]?[string]?<nl>" 16
418 Search backwards for the next occurrence of "string". If a count is
419 specified, the count becomes the new window size. Wrap around at the beginning
420 of the file does occur.
421 The final \fB<?>\fR is not required.
423 Repeat the last /[string]/ or ?[string]? search. Mnemonic: \fBn\fRext
426 Repeat the last /[string]/ or ?[string]? search, but in the reverse
428 .IP ":g/[string]/[editor command]<nl>" 16
430 Using the \fB:\fR syntax it is possible to do global searches ala the
431 standard UNIX "ed" editor.
436 The following commands allow for the insertion of text. All multicharacter
437 text insertions are terminated with an <esc> character.
439 can always be \fBundone\fR by typing a \fBu\fR.
440 The text insert in insertion mode can contain newlines.
443 Insert text immediately following the cursor position.
444 Mnemonic: \fBa\fRppend
446 Insert text at the end of the current line.
447 Mnemonic: \fBA\fRppend
449 Insert text immediately preceding the cursor position.
450 Mnemonic: \fBi\fRnsert
452 Insert text at the beginning of the current line.
454 Insert a new line after the line on which the cursor appears and
455 insert text there. Mnemonic: \fBo\fRpen new line
457 Insert a new line preceding the line on which the cursor appears
458 and insert text there.
463 The following commands allow the user to delete text in various ways.
464 All changes can always be \fBundone\fR by typing the \fBu\fR command.
467 Delete the character or characters starting at the cursor position.
469 Delete the character or characters starting at the character preceding
472 Deletes the remainder of the line starting at the cursor.
473 Mnemonic: \fBD\fRelete the rest of line
474 .IP "[cnt]d{motion}" 16
476 Deletes one or more occurrences of the specified motion.
477 Any motion from sections 4.1 and 4.2 can be used here.
478 The d can be stuttered (e.g. [cnt]dd) to delete cnt lines.
483 The following commands allow the user to simultaneously delete and
484 insert new text. All such actions can be \fBundone\fR by typing
485 \fBu\fR following the command.
488 Replaces the character at the current cursor position with <chr>. This
489 is a one character replacement. No <esc> is required for termination.
490 Mnemonic: \fBr\fReplace character
491 .IP "R{text}<esc>" 16
492 Starts overlaying the characters on the screen with whatever you type.
493 It does not stop until an <esc> is typed.
494 .IP "[cnt]s{text}<esc>" 16
495 Substitute for "cnt" characters beginning at the current cursor
496 position. A "$" will appear at the position in the text where the
497 "cnt"'th character appears so you will know how much you are erasing.
498 Mnemonic: \fBs\fRubstitute
499 .IP "[cnt]S{text}<esc>" 16
500 Substitute for the entire current line (or lines). If no count is given,
501 a "$" appears at the end of the current line. If a count of more than
502 1 is given, all the lines to be replaced are deleted before the insertion
504 .IP "[cnt]c{motion}{text}<esc>" 16
506 Change the specified "motion" by replacing it with the
507 insertion text. A "$" will appear at the end of the last item
508 that is being deleted unless the deletion involves whole lines.
509 Motion's can be any motion from sections 4.1 or 4.2.
510 Stuttering the c (e.g. [cnt]cc) changes cnt lines.
515 \fBVi\fR provides a number of ways of moving chunks of text around.
516 There are nine buffers into which each piece of text which is deleted
517 or "yanked" is put in addition to the "undo" buffer.
518 The most recent deletion or yank is in the "undo" buffer and also
520 1, the next most recent in buffer 2, and so forth. Each new deletion
521 pushes down all the older deletions. Deletions older than 9
522 disappear. There is also
523 a set of named registers, a-z, into which text can optionally
524 be placed. If any delete or replacement type command is preceded
525 by \fB"<a-z>\fR, that named buffer will contain the text deleted
526 after the command is executed. For example, \fB"a3dd\fR will delete
527 three lines starting at the current line and put them in buffer \fB"a\fR.*
529 * Referring to an upper case letter as a buffer name (A-Z) is the
530 same as referring to the lower case letter, except that text placed
531 in such a buffer is appended to it instead of replacing it.
533 There are two more basic commands and
534 some variations useful in getting and putting text into a file.
536 .IP ["<a-z>][cnt]y{motion} 16
538 Yank the specified item or "cnt" items and put in the "undo" buffer or
539 the specified buffer. The variety of "items" that can be yanked
540 is the same as those that can be deleted with the "d" command or
541 changed with the "c" command. In the same way that "dd" means
542 delete the current line and "cc" means replace the current line,
543 "yy" means yank the current line.
544 .IP ["<a-z>][cnt]Y 16
545 Yank the current line or the "cnt" lines starting from the current
546 line. If no buffer is specified, they will go into the "undo" buffer,
547 like any delete would. It is equivalent to "yy".
550 Put "undo" buffer or the specified buffer down \fBafter\fR the cursor.
551 If whole lines were yanked or deleted into the buffer, then they will be
552 put down on the line following the line the cursor is on. If
553 something else was deleted, like a word or sentence, then it will
554 be inserted immediately following the cursor.
555 Mnemonic: \fBp\fRut buffer
557 It should be noted that text in the named buffers remains there when you
558 start editing a new file with the \fB:e file<esc>\fR command. Since
559 this is so, it is possible to copy or delete text from one file and
560 carry it over to another file in the buffers.
561 However, the undo buffer and the ability to undo are lost when
564 Put "undo" buffer or the specified buffer down \fBbefore\fR the cursor.
565 If whole lines where yanked or deleted into the buffer, then they will be
566 put down on the line preceding the line the cursor is on. If
567 something else was deleted, like a word or sentence, then it will
568 be inserted immediately preceding the cursor.
569 .IP [cnt]>{motion} 16
570 The shift operator will right shift all the text from the line on which
571 the cursor is located to the line where the \fBmotion\fR is located.
572 The text is shifted by one \fBshiftwidth\fR. (See section 6.)
573 \fB>>\fR means right shift the current line or lines.
574 .IP [cnt]<{motion} 16
575 The shift operator will left shift all the text from the line on which
576 the cursor is located to the line where the \fBitem\fR is located.
577 The text is shifted by one \fBshiftwidth\fR. (See section 6.)
578 \fB<<\fR means left shift the current line or lines.
579 Once the line has reached the left margin it is not further affected.
580 .IP [cnt]={motion} 16
581 Prettyprints the indicated area according to
584 The area should be a lisp s-expression.
587 Miscellaneous Commands
589 \fBVi\fR has a number of miscellaneous commands that are very
593 This is the normal way to exit from vi.
594 If any changes have been made, the file is written out.
595 Then you are returned to the shell.
597 Redraw the current screen. This is useful if someone "write"s you
598 while you are in "vi" or if for any reason garbage gets onto the
601 On dumb terminals, those not having the "delete line" function
602 (the vt100 is such a terminal), \fBvi\fR saves redrawing the
603 screen when you delete a line by just marking the line with an
604 "@" at the beginning and blanking the line. If you want to
605 actually get rid of the lines marked with "@" and see what the
606 page looks like, typing a ^R will do this.
608 "Dot" is a particularly useful command. It repeats the last
609 text modifying command. Therefore you can type a command once and
610 then to another place and repeat it by just typing ".".
612 Perhaps the most important command in the editor,
613 u undoes the last command that changed the buffer.
616 Undo all the text modifying commands performed on the current line
617 since the last time you moved onto it.
619 Join the current line and the following line. The <nl> is deleted
620 and the two lines joined, usually with a space between the
621 end of the first line and the beginning of what was the second
622 line. If the first line ended with a "period", then two spaces
624 A count joins the next cnt lines.
625 Mnemonic: \fBJ\fRoin lines
627 Switch to \fBex\fR editing mode.
628 In this mode \fBvi\fR will behave very much like \fBed\fR.
629 The editor in this mode will operate on single lines normally and
630 will not attempt to keep the "window" up to date.
631 Once in this mode it is also possible to switch to the \fBopen\fR
632 mode of editing. By entering the command \fB[line number]open<nl>\fR
633 you enter this mode. It is similar to the normal visual mode
634 except the window is only \fBone\fR line long.
635 Mnemonic: \fBQ\fRuit visual mode
637 An abbreviation for a tag command.
638 The cursor should be positioned at the beginning of a word.
639 That word is taken as a tag name, and the tag with that
640 name is found as if it had been typed in a :tag command.
641 .IP [cnt]!{motion}{UNIX\ cmd}<nl> 16
644 (e.g. command that reads the standard input and outputs something
645 to the standard output) can be sent a section of the current file and
646 have the output of the command replace the original text. Useful
647 examples are programs like \fBcb\fR, \fBsort\fR, and
648 \fBnroff\fR. For instance, using \fBsort\fR it would be possible to
649 sort a section of the current file into a new list.
650 Using \fB!!\fR means take a line or lines starting at the line the
651 cursor is currently on and pass them to the UNIX command.
653 To just escape to the shell for one command,
654 use :!{cmd}<nl>, see section 5.
656 This resets the current window size to "cnt" lines and redraws the screen.
659 Special Insert Characters
661 There are some characters that have special meanings during
662 insert modes. They are:
665 During inserts, typing a ^V allows you to quote control characters
666 into the file. Any character typed after the ^V will be inserted
668 .IP [^]^D\ or\ [0]^D 16
669 <^D> without any argument backs up one \fBshiftwidth\fR. This is necessary
670 to remove indentation that was inserted by the \fBautoindent\fR feature.
671 ^<^D> temporarily removes all the autoindentation, thus placing the cursor
672 at the left margin. On the next line, the previous indent level will be
673 restored. This is useful for putting "labels" at the left margin.
674 0<^D> says remove all autoindents and stay that way. Thus the cursor
675 moves to the left margin and stays there on successive lines until
676 <tab>'s are typed. As with the <tab>, the <^D> is only effective before
677 any other "non-autoindent" controlling characters are typed.
678 Mnemonic: \fBD\fRelete a shiftwidth
680 If the cursor is sitting on a word, <^W> moves the cursor back to the beginning
681 of the word, thus erasing the word from the insert.
682 Mnemonic: erase \fBW\fRord
684 The backspace always serves as an erase during insert modes in addition
685 to your normal "erase" character. To insert a <bs> into your file, use
686 the <^V> to quote it.
691 Typing a ":" during command mode causes \fBvi\fR to put the cursor at
692 the bottom on the screen in preparation for a command. In the
693 ":" mode, \fBvi\fR can be given most \fBed\fR commands. It is
694 also from this mode that you exit from \fBvi\fR or switch to different
695 files. All commands of this variety are terminated by a <nl>, <cr>,
698 .IP ":w[!] [file]" 16
699 Causes \fBvi\fR to write out the current text to the disk. It is
700 written to the file you are editing unless "file" is supplied. If
701 "file" is supplied, the write is directed to that file instead. If
702 that file already exists, \fBvi\fR will not perform the write unless
703 the "!" is supplied indicating you
705 want to destroy the older copy of the file.
707 Causes \fBvi\fR to exit. If you have modified the file you are
708 looking at currently and haven't written it out, \fBvi\fR will
709 refuse to exit unless the "!" is supplied.
710 .IP ":e[!] [+[cmd]] [file]" 16
712 Start editing a new file called "file" or start editing the current
713 file over again. The command ":e!" says "ignore the changes I've made
714 to this file and start over from the beginning". It is useful if
715 you really mess up the file. The optional "+" says instead of starting
716 at the beginning, start at the "end", or,
717 if "cmd" is supplied, execute "cmd" first.
718 Useful cases of this are where cmd is "n" (any integer) which starts
720 and "/text", which searches for "text" and starts at the line where
723 Switch back to the place you were before your last tag command.
724 If your last tag command stayed within the file, ^^ returns to that tag.
725 If you have no recent tag command, it will return to the
726 same place in the previous file that it was showing when you switched
729 Start editing the next file in the argument list. Since \fBvi\fR
730 can be called with multiple file names, the ":n" command tells it to
731 stop work on the current file and switch to the next file. If the
732 current file was modifies, it has to be written out before the ":n"
733 will work or else the "!" must be supplied, which says discard the
734 changes I made to the current file.
735 .IP ":n[!] file [file file ...]" 16
737 Replace the current argument list with a new list of files and start
738 editing the first file in this new list.
740 Read in a copy of "file" on the line after the cursor.
742 Execute the "cmd" and take its output and put it into the file after
745 Execute any UNIX shell command.
748 looks in the file named
750 in the current directory.
752 is a file of lines in the format:
755 tag filename \fBvi\fR-search-command
757 If \fBvi\fR finds the tag you specified in the \fB:ta\fR command,
758 it stops editing the current file if necessary and if the current file is
759 up to date on the disk and switches to the file specified and uses the
760 search pattern specified to find the "tagged" item of interest. This
761 is particularly useful when editing multi-file C programs such as the
762 operating system. There is a program called \fBctags\fR which will
763 generate an appropriate \fBtags\fR file for C and f77
764 programs so that by saying
765 \fB:ta function<nl>\fR you will be switched to that function.
766 It could also be useful when editing multi-file documents, though the
767 \fBtags\fR file would have to be generated manually.
770 Special Arrangements for Startup
772 \fBVi\fR takes the value of \fB$TERM\fR and looks up the characteristics
773 of that terminal in the file \fB/etc/termcap\fR.
774 If you don't know \fBvi\fR's name for the terminal you are working
775 on, look in \fB/etc/termcap\fR.
777 When \fBvi\fR starts, it attempts to read the variable EXINIT
778 from your environment.*
779 If that exists, it takes the values in it as the default values
780 for certain of its internal constants. See the section on "Set Values"
782 If EXINIT doesn't exist you will get all the normal defaults.
784 * On version 6 systems
785 Instead of EXINIT, put the startup commands in the file .exrc
786 in your home directory.
789 Should you inadvertently hang up the phone while inside
791 or should the computer crash,
793 Upon returning to the system, type:
797 This will normally recover the file. If there is more than one
798 temporary file for a specific file name, \fBvi\fR recovers the
799 newest one. You can get an older version by recovering the
801 The command "vi -r" without a file name gives you the list of files
802 that were saved in the last system crash
805 the file just saved when the phone was hung up).
809 \fBVi\fR has a number of internal variables and switches which can be
810 set to achieve special affects.
811 These options come in three forms, those that are switches, which toggle
812 from off to on and back, those that require a numeric value, and those
813 that require an alphanumeric string value.
814 The toggle options are set by a command of the form:
818 and turned off with the command:
822 Commands requiring a value are set with a command of the form:
824 :set option=value<nl>
826 To display the value of a specific option type:
830 To display only those that you have changed type:
834 and to display the long table of all the settable parameters and
835 their current values type:
840 Most of the options have a long form and an abbreviation. Both are
841 listed in the following table as well as the normal default value.
843 To arrange to have values other than the default used every time you
846 place the appropriate
848 command in EXINIT in your environment, e.g.
850 EXINIT='set ai aw terse sh=/bin/csh'
855 setenv EXINIT 'set ai aw terse sh=/bin/csh'
862 These are usually placed in your .profile or .login.
863 If you are running a system without environments (such as version 6)
864 you can place the set command in the file .exrc in your home
867 .IP autoindent\ ai 16
868 Default: noai Type: toggle
870 When in autoindent mode, vi helps you indent code by starting each
871 line in the same column as the preceding line.
872 Tabbing to the right with <tab> or <^T> will move this boundary to
873 the right, and it can be moved to the left with <^D>.
875 Default: ap Type: toggle
877 Causes the current line to be printed after each ex text modifying command.
878 This is not of much interest in the normal \fBvi\fR visual mode.
880 Default: noaw type: toggle
882 Autowrite causes an automatic write to be done if there are unsaved
883 changes before certain commands which change files or otherwise
884 interact with the outside world.
885 These commands are :!, :tag, :next, :rewind, ^^, and ^].
887 Default: nobf Type: toggle
889 Causes all control characters except <tab>, <nl>, and <ff> to be discarded.
890 .IP directory\ dir 16
891 Default: dir=/tmp Type: string
893 This is the directory in which \fBvi\fR puts its temporary file.
894 .IP errorbells\ eb 16
895 Default: noeb Type: toggle
897 Error messages are preceded by a <bell>.
899 Default: hardtabs=8 Type: numeric
901 This option contains the value of hardware tabs in your terminal, or
902 of software tabs expanded by the Unix system.
903 .IP ignorecase\ ic 16
904 Default: noic Type: toggle
906 All upper case characters are mapped to lower case in regular expression
909 Default: nolisp Type: toggle
911 Autoindent for \fBlisp\fR code. The commands \fB( ) [[\fR and \fB]]\fR
912 are modified appropriately to affect s-expressions and functions.
914 Default: nolist Type: toggle
916 All printed lines have the <tab> and <nl> characters displayed visually.
918 Default: magic Type: toggle
920 Enable the metacharacters for matching. These include \fB. * < > [string]
921 [^string]\fR and \fB[<chr>-<chr>]\fR.
923 Default: nonu Type: toggle
925 Each line is displayed with its line number.
927 Default: open Type: toggle
929 When set, prevents entering open or visual modes from ex or edit.
930 Not of interest from vi.
932 Default: opt Type: toggle
934 Basically of use only when using the \fBex\fR capabilities. This
935 option prevents automatic <cr>s from taking place,
936 and speeds up output of indented lines,
937 at the expense of losing typeahead on some versions of UNIX.
938 .IP paragraphs\ para 16
939 Default: para=IPLPPPQPP\ bp Type: string
941 Each pair of characters in the string indicate \fBnroff\fR macros
942 which are to be treated as the beginning of a paragraph for the
943 \fB{\fR and \fB}\fR commands. The default string is for the \fB-ms\fR
944 and \fB-mm\fR macros.
945 To indicate one letter \fBnroff\fR macros, such as \fB.P\fR or \fB.H\fR,
946 quote a space in for the second character position. For example:
949 :set paragraphs=P\e bp<nl>
951 would cause \fBvi\fR to consider \fB.P\fR and \fB.bp\fR as paragraph
954 Default: prompt Type: toggle
958 command mode the prompt character \fB:\fR will be printed when
959 \fBex\fR is waiting for a command. This is not of interest from vi.
961 Default: noredraw Type: toggle
963 On dumb terminals, force the screen to always be up to date,
964 by sending great amounts of output. Useful only at high speeds.
966 Default: report=5 Type: numeric
968 This sets the threshold for the number of lines modified. When
969 more than this number of lines are modified, removed, or yanked,
970 \fBvi\fR will report the number of lines changed at the bottom of
973 Default: scroll={1/2 window} Type: numeric
975 This is the number of lines that the screen scrolls up or down when
976 using the <^U> and <^D> commands.
978 Default: sections=SHNHH HU Type: string
980 Each two character pair of this string specify \fBnroff\fR macro names
981 which are to be treated as the beginning of a section by the
982 \fB]]\fR and \fB[[\fR commands. The default string is for the \fB-ms\fR
983 and \fB-mm\fR macros.
984 To enter one letter \fBnroff\fR macros, use a quoted space as the
986 See \fBparagraphs\fR for a fuller explanation.
988 Default: sh=from environment SHELL or /bin/sh Type: string
990 This is the name of the \fBsh\fR to be used for "escaped" commands.
991 .IP shiftwidth\ sw 16
992 Default: sw=8 Type: numeric
994 This is the number of spaces that a <^T> or <^D> will move over for
995 indenting, and the amount < and > shift by.
997 Default: nosm Type: toggle
999 When a \fB)\fR or \fB}\fR is typed, show the matching \fB(\fR or \fB{\fR
1000 by moving the cursor to it for one second if it is on the current screen.
1001 .IP slowopen\ slow 16
1002 Default: terminal dependent Type: toggle
1004 On terminals that are slow and unintelligent, this option prevents the
1005 updating of the screen some of the time to improve speed.
1007 Default: ts=8 Type: numeric
1009 <tab>s are expanded to boundaries that are multiples of this value.
1010 .IP taglength\ tl 16
1011 Default: tl=0 Type: numeric
1013 If nonzero, tag names are only significant to this many characters.
1015 Default: (from environment \fBTERM\fP, else dumb) Type: string
1017 This is the terminal and controls the visual displays. It cannot be
1018 changed when in "visual" mode,
1019 you have to Q to command mode, type a
1020 set term command, and do ``vi.'' to get back into visual.
1021 Or exit vi, fix $TERM, and reenter.
1022 The definitions that drive a particular
1023 terminal type are found in the file \fB/etc/termcap\fR.
1025 Default: terse Type: toggle
1027 When set, the error diagnostics are short.
1029 Default: warn Type: toggle
1031 The user is warned if she/he tries to escape to
1032 the shell without writing out the current changes.
1034 Default: window={8 at 600 baud or less, 16 at 1200 baud, and screen
1035 size \- 1 at 2400 baud or more} Type: numeric
1037 This is the number of lines in the window whenever \fBvi\fR must redraw
1038 an entire screen. It is useful to make this size smaller if you are
1040 .IP w300,\ w1200,\ w9600
1042 These set window, but only within the corresponding speed ranges.
1043 They are useful in an EXINIT to fine tune window sizes.
1048 causes a 4 lines window at speed up to 600 baud, a 12 line window at 1200
1049 baud, and a full screen (the default) at over 1200 baud.
1051 Default: ws Type: toggle
1053 Searches will wrap around the end of the file when is option is set. When
1054 it is off, the search will terminate when it reaches the end or the
1055 beginning of the file.
1056 .IP wrapmargin\ wm 16
1057 Default: wm=0 Type: numeric
1059 \fBVi\fR will automatically insert a <nl> when it finds a natural
1060 break point (usually a <sp> between words) that occurs within
1061 "wm" spaces of the right margin.
1062 Therefore with "wm=0" the option is off. Setting it to 10 would
1063 mean that any time you are within 10 spaces of the right margin
1064 \fBvi\fR would be looking for a <sp> or <tab> which it could
1065 replace with a <nl>. This is convenient for people who forget
1066 to look at the screen while they type.
1067 (In version 3, wrapmargin behaves more like nroff, in that the
1068 boundary specified by the distance from the right edge of the screen
1069 is taken as the rightmost edge of the area where a break is allowed,
1070 instead of the leftmost edge.)
1072 Default: nowa Type: toggle
1074 \fBVi\fR normally makes a number of checks before it writes out a file.
1075 This prevents the user from inadvertently destroying a file. When the
1076 "writeany" option is enabled, \fBvi\fR no longer makes these checks.