1 .\" Copyright (c) 1980, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" %sccs.include.redist.roff%
6 .\" $Id: vi.apwh.ms,v 8.1 1993/06/08 12:49:26 bostic Exp $ (Berkeley) $Date: 1993/06/08 12:49:26 $
9 Vi Command & Function Reference
13 Revised for version 2.12 by Mark Horton
18 This document does not claim to be 100% complete. There are a
19 few commands listed in the original document that I was unable
20 to test either because I do not speak \fBlisp\fR, because they
21 required programs we don't have, or because I wasn't able to make
22 them work. In these cases I left the command out. The commands
23 listed in this document have been tried and are known to work.
24 It is expected that prospective users of this document will read
25 it once to get the flavor of everything that \fBvi\fR can do
26 and then use it as a reference document. Experimentation is
27 recommended. If you don't understand a command, try it and
30 [Note: In revising this document, I have attempted to make it
31 completely reflect version 2.12 of
33 It does not attempt to document the VAX version (version 3),
34 but with one or two exceptions (wrapmargin, arrow keys)
35 everything said about 2.12 should apply to 3.1.
40 \fB[option]\fR is used to denote optional parts of a command.
41 Many \fBvi\fR commands have an optional count. \fB[cnt]\fR
42 means that an optional number may precede the command to
43 multiply or iterate the command.
44 \fB{variable item}\fR is used to denote parts of the command
45 which must appear, but can take a number of different values.
46 \fB<character [-character]>\fR means that the character or
47 one of the characters in the range described between the
48 two angle brackets is to be typed.
49 For example \fB<esc>\fR means
50 the \fBescape\fR key is to be typed. \fB<a-z>\fR means that a
51 lower case letter is to be typed. \fB^<character>\fR means that
52 the character is to be typed as a \fBcontrol\fR character, that is,
53 with the \fB<cntl>\fR key held down while simultaneously typing
54 the specified character. In this document control characters will
55 be denoted using the \fIupper case\fR character, but
56 ^<uppercase chr> and ^<lowercase chr> are equivalent. That is, for
57 example, \fB<^D>\fR is equal to \fB<^d>\fR.
58 The most common character abbreviations
59 used in this list are as follows:
64 carriage return, ^M, octal 015
66 linefeed ^J, octal 012
68 newline, ^J, octal 012 (same as linefeed)
70 backspace, ^H, octal 010
76 formfeed, ^L, octal 014
86 To run \fBvi\fR the shell variable \fBTERM\fR must be defined and
87 exported to your environment.
88 How you do this depends on which shell you are using.
89 You can tell which shell you have by the character it
90 prompts you for commands with.
91 The Bourne shell prompts with `$', and the C shell prompts with `%'.
92 For these examples, we will suppose
93 that you are using an HP 2621 terminal, whose termcap name is ``2621''.
97 To manually set your terminal type to 2621 you would type:
103 There are various ways of having this automatically or
104 semi-automatically done when you log in.
105 Suppose you usually dial in on a 2621.
106 You want to tell this to the machine, but still have it
107 work when you use a hardwired terminal.
108 The recommended way, if you have the
110 program, is to use the sequence
112 tset \-s \-d 2621 > tset$$
116 in your .login (for csh) or the same thing using `.' instead of `source'
117 in your .profile (for sh).
118 The above line says that if you are dialing in you are on a 2621,
119 but if you are on a hardwired terminal it figures out your terminal
120 type from an on-line list.
124 To manually set your terminal type to 2621 you would type:
129 There are various ways of having this automatically or
130 semi-automatically done when you log in.
131 Suppose you usually dial in on a 2621.
132 You want to tell this to the machine, but still have it
133 work when you use a hardwired terminal.
134 The recommended way, if you have the
136 program, is to use the sequence
138 tset \-s \-d 2621 > tset$$
144 * On a version 6 system
145 without environments, the invocation of tset
146 is simpler, just add the line ``tset \-d 2621''
147 to your .login or .profile.
149 The above line says that if you are dialing in you are on a 2621,
150 but if you are on a hardwired terminal it figures out your terminal
151 type from an on-line list.
155 \fBVi\fR is a visual editor with a window on the file. What
156 you see on the screen is \fBvi\fR's current notion of
157 what your file will contain,
158 (at this point in the file),
159 when it is written out.
160 Most commands do not cause any change in the screen until the
161 complete command is typed. Should you get confused while
162 typing a command, you can abort the command by typing an
163 <del> character. You will know you are back to command level
164 when you hear a <bell>. Usually typing an <esc> will produce the
165 same result. When \fBvi\fR gets an improperly formatted command
167 Following are the \fBvi\fR commands broken down by function.
179 The file will be read in and the cursor will be placed at the beginning
181 The first screenfull of the file will be displayed on the terminal.
183 To get out of the editor, type
187 If you are in some special mode, such as input mode
188 or the middle of a multi-keystroke command, it may
189 be necessary to type <esc> first.
191 Cursor and Page Motion
195 The arrow keys (see the next four commands)
196 on certain kinds of terminals will not work with the
197 PDP-11 version of vi. The control versions or the hjkl versions will
198 work on any terminal. Experienced users prefer the hjkl keys because
199 they are always right under their fingers. Beginners often prefer
200 the arrow keys, since they do not require memorization of which hjkl
202 The mnemonic value of hjkl is clear from looking at the keyboard of an adm3a.
204 .IP "[cnt]<bs> or [cnt]h or [cnt]\(<-" 16
206 Move the cursor to the left one character. Cursor stops at the left
208 If cnt is given, these commands move that many spaces.
209 .IP "[cnt]^N or [cnt]j or [cnt]\(da or [cnt]<lf>" 16
212 Moving off the screen scrolls the window to force a new line
215 .IP "[cnt]^P or [cnt]k or [cnt]\(ua" 16
218 Moving off the top of the screen forces new text onto the screen.
219 Mnemonic: \fBP\fRrevious
220 .IP "[cnt]<sp> or [cnt]l or [cnt]\(->" 16
222 Move to the right one character.
223 Cursor will not go beyond the end of the line.
225 Move the cursor up the screen to the beginning of the next line.
227 .IP "[cnt]+ or [cnt]<cr>" 16
229 Move the cursor down the screen to the beginning of the next line.
230 Scroll up if necessary.
232 Move the cursor to the end of the line.
233 If there is a count, move to the end of the line "cnt" lines
236 Move the cursor to the beginning of the first word on the line.
238 Move the cursor to the left margin of the current line.
240 Move the cursor to the column specified by the count. The default is
243 Move the cursor to the beginning of the next word. If there
244 is a count, then move forward that many words and
245 position the cursor at the beginning of the word.
246 Mnemonic: next-\fBw\fRord
248 Move the cursor to the beginning of the next word which follows
249 a "white space" (<sp>,<tab>, or <nl>). Ignore other punctuation.
251 Move the cursor to the preceding word. Mnemonic: \fBb\fRackup-word
253 Move the cursor to the preceding word that is separated from the
254 current word by a "white space" (<sp>,<tab>, or <nl>).
256 Move the cursor to the end of the current word or the end of the
257 "cnt"'th word hence. Mnemonic: \fBe\fRnd-of-word
259 Move the cursor to the end of the current word which is delimited by
260 "white space" (<sp>,<tab>, or <nl>).
261 .IP "[line number]G" 16
263 Move the cursor to the line specified. Of particular use are the
264 sequences "1G" and "G", which move the cursor to the beginning and
265 the end of the file respectively. Mnemonic: \fBG\fRo-to
268 The next four commands (^D, ^U, ^F, ^B)
269 are not true motion commands, in that they
270 cannot be used as the object of commands such as delete or change.
272 Move the cursor down in the file by "cnt" lines (or the last "cnt"
273 if a new count isn't given. The initial default is half a page.) The
274 screen is simultaneously scrolled up. Mnemonic: \fBD\fRown
276 Move the cursor up in the file by "cnt" lines. The screen is simultaneously
277 scrolled down. Mnemonic: \fBU\fRp
279 Move the cursor to the next page. A count moves that many pages.
280 Two lines of the previous page are kept on the screen for continuity if
281 possible. Mnemonic: \fBF\fRorward-a-page
283 Move the cursor to the previous page. Two lines of the current page
284 are kept if possible. Mnemonic: \fBB\fRackup-a-page
286 Move the cursor to the beginning of the next sentence.
287 A sentence is defined as ending with a ".", "!", or "?"
288 followed by two spaces or a <nl>.
290 Move the cursor backwards to the beginning of a sentence.
292 Move the cursor to the beginning of the next paragraph. This command
293 works best inside \fBnroff\fR documents. It understands two sets of
294 \fBnroff\fR macros, \fB\-ms\fR and \fB\-mm\fR, for which the
295 commands ".IP", ".LP", ".PP", ".QP", "P", as well as the nroff command ".bp"
296 are considered to be paragraph delimiters.
297 A blank line also delimits a paragraph.
298 The \fBnroff\fR macros that it accepts as paragraph delimiters is
299 adjustable. See \fBparagraphs\fR under the \fBSet Commands\fR section.
301 Move the cursor backwards to the beginning of a paragraph.
303 Move the cursor to the next "section", where a section is defined by
304 two sets of \fBnroff\fR macros, \fB\-ms\fR and \fB\-mm\fR, in which
305 ".NH", ".SH", and ".H" delimit a section. A line beginning with a <ff><nl>
306 sequence, or a line beginning with a "{" are also considered to
307 be section delimiters. The last option makes it
308 useful for finding the beginnings of C functions.
309 The \fBnroff\fR macros that are used for section delimiters can be adjusted.
310 See \fBsections\fR under the \fBSet Commands\fR section.
312 Move the cursor backwards to the beginning of a section.
314 Move the cursor to the matching parenthesis
315 or brace. This is very useful in C or lisp code. If the
316 cursor is sitting on a \fB( ) {\fR or \fB}\fR the cursor
317 is moved to the matching character at the other end of the
318 section. If the cursor is not sitting on a brace or a
319 parenthesis, \fBvi\fR searches forward until it finds one
320 and then jumps to the match mate.
322 If there is no count move the cursor to the top left position on the screen.
323 If there is a count, then move the cursor to the beginning of the line
324 "cnt" lines from the top of the screen. Mnemonic: \fBH\fRome
326 If there is no count move the cursor to the beginning
327 of the last line on the screen.
328 If there is a count, then move the cursor to the beginning of the line
329 "cnt" lines from the bottom of the screen. Mnemonic: \fBL\fRast
331 Move the cursor to the beginning of the middle line on the screen.
332 Mnemonic: \fBM\fRiddle
334 This command does not move the cursor, but it \fBmarks\fR the place
335 in the file and the character "<a-z>" becomes the label for referring
336 to this location in the file. See the next two commands. Mnemonic:
339 The mark command is not a motion, and cannot be used as the target
340 of commands such as delete.
342 Move the cursor to the beginning of the line that is marked with the label
345 Move the cursor to the exact position on the line that was marked with
346 with the label "<a-z>".
348 Move the cursor back to the beginning of the line where it was before the
349 last "non-relative" move. A "non-relative" move is something such as a
350 search or a jump to a specific line in the file, rather than moving the
351 cursor or scrolling the screen.
353 Move the cursor back to the exact spot on the line where it was located
354 before the last "non-relative" move.
359 The following commands allow you to search for items in a file.
363 Search forward on the line for the next or "cnt"'th occurrence of
364 the character "chr". The cursor is placed \fBat\fR the character
365 of interest. Mnemonic: \fBf\fRind character
368 Search backwards on the line for the next or "cnt"'th occurrence of
369 the character "chr". The cursor is placed \fBat\fR the character
373 Search forward on the line for the next or "cnt"'th occurrence of
374 the character "chr". The cursor is placed \fBjust preceding\fR
375 the character of interest. Mnemonic: move cursor up \fBt\fRo character
378 Search backwards on the line for the next or "cnt"'th occurrence of
379 the character "chr". The cursor is placed \fBjust preceding\fR
380 the character of interest.
382 Repeat the last "f", "F", "t" or "T" command.
384 Repeat the last "f", "F", "t" or "T" command, but in the opposite
385 search direction. This is useful if you overshoot.
386 .IP "[cnt]/[string]/<nl>" 16
388 Search forward for the next occurrence of "string".
389 Wrap around at the end of the file
391 The final \fB</>\fR is not required.
392 .IP "[cnt]?[string]?<nl>" 16
394 Search backwards for the next occurrence of "string". If a count is
395 specified, the count becomes the new window size. Wrap around at the beginning
396 of the file does occur.
397 The final \fB<?>\fR is not required.
399 Repeat the last /[string]/ or ?[string]? search. Mnemonic: \fBn\fRext
402 Repeat the last /[string]/ or ?[string]? search, but in the reverse
404 .IP ":g/[string]/[editor command]<nl>" 16
406 Using the \fB:\fR syntax it is possible to do global searches ala the
407 standard UNIX "ed" editor.
412 The following commands allow for the insertion of text. All multicharacter
413 text insertions are terminated with an <esc> character.
415 can always be \fBundone\fR by typing a \fBu\fR.
416 The text insert in insertion mode can contain newlines.
419 Insert text immediately following the cursor position.
420 Mnemonic: \fBa\fRppend
422 Insert text at the end of the current line.
423 Mnemonic: \fBA\fRppend
425 Insert text immediately preceding the cursor position.
426 Mnemonic: \fBi\fRnsert
428 Insert text at the beginning of the current line.
430 Insert a new line after the line on which the cursor appears and
431 insert text there. Mnemonic: \fBo\fRpen new line
433 Insert a new line preceding the line on which the cursor appears
434 and insert text there.
439 The following commands allow the user to delete text in various ways.
440 All changes can always be \fBundone\fR by typing the \fBu\fR command.
443 Delete the character or characters starting at the cursor position.
445 Delete the character or characters starting at the character preceding
448 Deletes the remainder of the line starting at the cursor.
449 Mnemonic: \fBD\fRelete the rest of line
450 .IP "[cnt]d{motion}" 16
452 Deletes one or more occurrences of the specified motion.
453 Any motion from sections 4.1 and 4.2 can be used here.
454 The d can be stuttered (e.g. [cnt]dd) to delete cnt lines.
459 The following commands allow the user to simultaneously delete and
460 insert new text. All such actions can be \fBundone\fR by typing
461 \fBu\fR following the command.
464 Replaces the character at the current cursor position with <chr>. This
465 is a one character replacement. No <esc> is required for termination.
466 Mnemonic: \fBr\fReplace character
467 .IP "R{text}<esc>" 16
468 Starts overlaying the characters on the screen with whatever you type.
469 It does not stop until an <esc> is typed.
470 .IP "[cnt]s{text}<esc>" 16
471 Substitute for "cnt" characters beginning at the current cursor
472 position. A "$" will appear at the position in the text where the
473 "cnt"'th character appears so you will know how much you are erasing.
474 Mnemonic: \fBs\fRubstitute
475 .IP "[cnt]S{text}<esc>" 16
476 Substitute for the entire current line (or lines). If no count is given,
477 a "$" appears at the end of the current line. If a count of more than
478 1 is given, all the lines to be replaced are deleted before the insertion
480 .IP "[cnt]c{motion}{text}<esc>" 16
482 Change the specified "motion" by replacing it with the
483 insertion text. A "$" will appear at the end of the last item
484 that is being deleted unless the deletion involves whole lines.
485 Motion's can be any motion from sections 4.1 or 4.2.
486 Stuttering the c (e.g. [cnt]cc) changes cnt lines.
491 \fBVi\fR provides a number of ways of moving chunks of text around.
492 There are nine buffers into which each piece of text which is deleted
493 or "yanked" is put in addition to the "undo" buffer.
494 The most recent deletion or yank is in the "undo" buffer and also
496 1, the next most recent in buffer 2, and so forth. Each new deletion
497 pushes down all the older deletions. Deletions older than 9
498 disappear. There is also
499 a set of named registers, a-z, into which text can optionally
500 be placed. If any delete or replacement type command is preceded
501 by \fB"<a-z>\fR, that named buffer will contain the text deleted
502 after the command is executed. For example, \fB"a3dd\fR will delete
503 three lines starting at the current line and put them in buffer \fB"a\fR.*
505 * Referring to an upper case letter as a buffer name (A-Z) is the
506 same as referring to the lower case letter, except that text placed
507 in such a buffer is appended to it instead of replacing it.
509 There are two more basic commands and
510 some variations useful in getting and putting text into a file.
512 .IP ["<a-z>][cnt]y{motion} 16
514 Yank the specified item or "cnt" items and put in the "undo" buffer or
515 the specified buffer. The variety of "items" that can be yanked
516 is the same as those that can be deleted with the "d" command or
517 changed with the "c" command. In the same way that "dd" means
518 delete the current line and "cc" means replace the current line,
519 "yy" means yank the current line.
520 .IP ["<a-z>][cnt]Y 16
521 Yank the current line or the "cnt" lines starting from the current
522 line. If no buffer is specified, they will go into the "undo" buffer,
523 like any delete would. It is equivalent to "yy".
526 Put "undo" buffer or the specified buffer down \fBafter\fR the cursor.
527 If whole lines were yanked or deleted into the buffer, then they will be
528 put down on the line following the line the cursor is on. If
529 something else was deleted, like a word or sentence, then it will
530 be inserted immediately following the cursor.
531 Mnemonic: \fBp\fRut buffer
533 It should be noted that text in the named buffers remains there when you
534 start editing a new file with the \fB:e file<esc>\fR command. Since
535 this is so, it is possible to copy or delete text from one file and
536 carry it over to another file in the buffers.
537 However, the undo buffer and the ability to undo are lost when
540 Put "undo" buffer or the specified buffer down \fBbefore\fR the cursor.
541 If whole lines where yanked or deleted into the buffer, then they will be
542 put down on the line preceding the line the cursor is on. If
543 something else was deleted, like a word or sentence, then it will
544 be inserted immediately preceding the cursor.
545 .IP [cnt]>{motion} 16
546 The shift operator will right shift all the text from the line on which
547 the cursor is located to the line where the \fBmotion\fR is located.
548 The text is shifted by one \fBshiftwidth\fR. (See section 6.)
549 \fB>>\fR means right shift the current line or lines.
550 .IP [cnt]<{motion} 16
551 The shift operator will left shift all the text from the line on which
552 the cursor is located to the line where the \fBitem\fR is located.
553 The text is shifted by one \fBshiftwidth\fR. (See section 6.)
554 \fB<<\fR means left shift the current line or lines.
555 Once the line has reached the left margin it is not further affected.
556 .IP [cnt]={motion} 16
557 Prettyprints the indicated area according to
560 The area should be a lisp s-expression.
563 Miscellaneous Commands
565 \fBVi\fR has a number of miscellaneous commands that are very
569 This is the normal way to exit from vi.
570 If any changes have been made, the file is written out.
571 Then you are returned to the shell.
573 Redraw the current screen. This is useful if someone "write"s you
574 while you are in "vi" or if for any reason garbage gets onto the
577 On dumb terminals, those not having the "delete line" function
578 (the vt100 is such a terminal), \fBvi\fR saves redrawing the
579 screen when you delete a line by just marking the line with an
580 "@" at the beginning and blanking the line. If you want to
581 actually get rid of the lines marked with "@" and see what the
582 page looks like, typing a ^R will do this.
584 "Dot" is a particularly useful command. It repeats the last
585 text modifying command. Therefore you can type a command once and
586 then to another place and repeat it by just typing ".".
588 Perhaps the most important command in the editor,
589 u undoes the last command that changed the buffer.
592 Undo all the text modifying commands performed on the current line
593 since the last time you moved onto it.
595 Join the current line and the following line. The <nl> is deleted
596 and the two lines joined, usually with a space between the
597 end of the first line and the beginning of what was the second
598 line. If the first line ended with a "period", then two spaces
600 A count joins the next cnt lines.
601 Mnemonic: \fBJ\fRoin lines
603 Switch to \fBex\fR editing mode.
604 In this mode \fBvi\fR will behave very much like \fBed\fR.
605 The editor in this mode will operate on single lines normally and
606 will not attempt to keep the "window" up to date.
607 Once in this mode it is also possible to switch to the \fBopen\fR
608 mode of editing. By entering the command \fB[line number]open<nl>\fR
609 you enter this mode. It is similar to the normal visual mode
610 except the window is only \fBone\fR line long.
611 Mnemonic: \fBQ\fRuit visual mode
613 An abbreviation for a tag command.
614 The cursor should be positioned at the beginning of a word.
615 That word is taken as a tag name, and the tag with that
616 name is found as if it had been typed in a :tag command.
617 .IP [cnt]!{motion}{UNIX\ cmd}<nl> 16
620 (e.g. command that reads the standard input and outputs something
621 to the standard output) can be sent a section of the current file and
622 have the output of the command replace the original text. Useful
623 examples are programs like \fBcb\fR, \fBsort\fR, and
624 \fBnroff\fR. For instance, using \fBsort\fR it would be possible to
625 sort a section of the current file into a new list.
626 Using \fB!!\fR means take a line or lines starting at the line the
627 cursor is currently on and pass them to the UNIX command.
629 To just escape to the shell for one command,
630 use :!{cmd}<nl>, see section 5.
632 This resets the current window size to "cnt" lines and redraws the screen.
635 Special Insert Characters
637 There are some characters that have special meanings during
638 insert modes. They are:
641 During inserts, typing a ^V allows you to quote control characters
642 into the file. Any character typed after the ^V will be inserted
644 .IP [^]^D\ or\ [0]^D 16
645 <^D> without any argument backs up one \fBshiftwidth\fR. This is necessary
646 to remove indentation that was inserted by the \fBautoindent\fR feature.
647 ^<^D> temporarily removes all the autoindentation, thus placing the cursor
648 at the left margin. On the next line, the previous indent level will be
649 restored. This is useful for putting "labels" at the left margin.
650 0<^D> says remove all autoindents and stay that way. Thus the cursor
651 moves to the left margin and stays there on successive lines until
652 <tab>'s are typed. As with the <tab>, the <^D> is only effective before
653 any other "non-autoindent" controlling characters are typed.
654 Mnemonic: \fBD\fRelete a shiftwidth
656 If the cursor is sitting on a word, <^W> moves the cursor back to the beginning
657 of the word, thus erasing the word from the insert.
658 Mnemonic: erase \fBW\fRord
660 The backspace always serves as an erase during insert modes in addition
661 to your normal "erase" character. To insert a <bs> into your file, use
662 the <^V> to quote it.
667 Typing a ":" during command mode causes \fBvi\fR to put the cursor at
668 the bottom on the screen in preparation for a command. In the
669 ":" mode, \fBvi\fR can be given most \fBed\fR commands. It is
670 also from this mode that you exit from \fBvi\fR or switch to different
671 files. All commands of this variety are terminated by a <nl>, <cr>,
674 .IP ":w[!] [file]" 16
675 Causes \fBvi\fR to write out the current text to the disk. It is
676 written to the file you are editing unless "file" is supplied. If
677 "file" is supplied, the write is directed to that file instead. If
678 that file already exists, \fBvi\fR will not perform the write unless
679 the "!" is supplied indicating you
681 want to destroy the older copy of the file.
683 Causes \fBvi\fR to exit. If you have modified the file you are
684 looking at currently and haven't written it out, \fBvi\fR will
685 refuse to exit unless the "!" is supplied.
686 .IP ":e[!] [+[cmd]] [file]" 16
688 Start editing a new file called "file" or start editing the current
689 file over again. The command ":e!" says "ignore the changes I've made
690 to this file and start over from the beginning". It is useful if
691 you really mess up the file. The optional "+" says instead of starting
692 at the beginning, start at the "end", or,
693 if "cmd" is supplied, execute "cmd" first.
694 Useful cases of this are where cmd is "n" (any integer) which starts
696 and "/text", which searches for "text" and starts at the line where
699 Switch back to the place you were before your last tag command.
700 If your last tag command stayed within the file, ^^ returns to that tag.
701 If you have no recent tag command, it will return to the
702 same place in the previous file that it was showing when you switched
705 Start editing the next file in the argument list. Since \fBvi\fR
706 can be called with multiple file names, the ":n" command tells it to
707 stop work on the current file and switch to the next file. If the
708 current file was modifies, it has to be written out before the ":n"
709 will work or else the "!" must be supplied, which says discard the
710 changes I made to the current file.
711 .IP ":n[!] file [file file ...]" 16
713 Replace the current argument list with a new list of files and start
714 editing the first file in this new list.
716 Read in a copy of "file" on the line after the cursor.
718 Execute the "cmd" and take its output and put it into the file after
721 Execute any UNIX shell command.
724 looks in the file named
726 in the current directory.
728 is a file of lines in the format:
731 tag filename \fBvi\fR-search-command
733 If \fBvi\fR finds the tag you specified in the \fB:ta\fR command,
734 it stops editing the current file if necessary and if the current file is
735 up to date on the disk and switches to the file specified and uses the
736 search pattern specified to find the "tagged" item of interest. This
737 is particularly useful when editing multi-file C programs such as the
738 operating system. There is a program called \fBctags\fR which will
739 generate an appropriate \fBtags\fR file for C and f77
740 programs so that by saying
741 \fB:ta function<nl>\fR you will be switched to that function.
742 It could also be useful when editing multi-file documents, though the
743 \fBtags\fR file would have to be generated manually.
746 Special Arrangements for Startup
748 \fBVi\fR takes the value of \fB$TERM\fR and looks up the characteristics
749 of that terminal in the file \fB/etc/termcap\fR.
750 If you don't know \fBvi\fR's name for the terminal you are working
751 on, look in \fB/etc/termcap\fR.
753 When \fBvi\fR starts, it attempts to read the variable EXINIT
754 from your environment.*
755 If that exists, it takes the values in it as the default values
756 for certain of its internal constants. See the section on "Set Values"
758 If EXINIT doesn't exist you will get all the normal defaults.
760 * On version 6 systems
761 Instead of EXINIT, put the startup commands in the file .exrc
762 in your home directory.
765 Should you inadvertently hang up the phone while inside
767 or should the computer crash,
769 Upon returning to the system, type:
773 This will normally recover the file. If there is more than one
774 temporary file for a specific file name, \fBvi\fR recovers the
775 newest one. You can get an older version by recovering the
777 The command "vi -r" without a file name gives you the list of files
778 that were saved in the last system crash
781 the file just saved when the phone was hung up).
785 \fBVi\fR has a number of internal variables and switches which can be
786 set to achieve special affects.
787 These options come in three forms, those that are switches, which toggle
788 from off to on and back, those that require a numeric value, and those
789 that require an alphanumeric string value.
790 The toggle options are set by a command of the form:
794 and turned off with the command:
798 Commands requiring a value are set with a command of the form:
800 :set option=value<nl>
802 To display the value of a specific option type:
806 To display only those that you have changed type:
810 and to display the long table of all the settable parameters and
811 their current values type:
816 Most of the options have a long form and an abbreviation. Both are
817 listed in the following table as well as the normal default value.
819 To arrange to have values other than the default used every time you
822 place the appropriate
824 command in EXINIT in your environment, e.g.
826 EXINIT='set ai aw terse sh=/bin/csh'
831 setenv EXINIT 'set ai aw terse sh=/bin/csh'
838 These are usually placed in your .profile or .login.
839 If you are running a system without environments (such as version 6)
840 you can place the set command in the file .exrc in your home
843 .IP autoindent\ ai 16
844 Default: noai Type: toggle
846 When in autoindent mode, vi helps you indent code by starting each
847 line in the same column as the preceding line.
848 Tabbing to the right with <tab> or <^T> will move this boundary to
849 the right, and it can be moved to the left with <^D>.
851 Default: ap Type: toggle
853 Causes the current line to be printed after each ex text modifying command.
854 This is not of much interest in the normal \fBvi\fR visual mode.
856 Default: noaw type: toggle
858 Autowrite causes an automatic write to be done if there are unsaved
859 changes before certain commands which change files or otherwise
860 interact with the outside world.
861 These commands are :!, :tag, :next, :rewind, ^^, and ^].
863 Default: nobf Type: toggle
865 Causes all control characters except <tab>, <nl>, and <ff> to be discarded.
866 .IP directory\ dir 16
867 Default: dir=/tmp Type: string
869 This is the directory in which \fBvi\fR puts its temporary file.
870 .IP errorbells\ eb 16
871 Default: noeb Type: toggle
873 Error messages are preceded by a <bell>.
875 Default: hardtabs=8 Type: numeric
877 This option contains the value of hardware tabs in your terminal, or
878 of software tabs expanded by the Unix system.
879 .IP ignorecase\ ic 16
880 Default: noic Type: toggle
882 All upper case characters are mapped to lower case in regular expression
885 Default: nolisp Type: toggle
887 Autoindent for \fBlisp\fR code. The commands \fB( ) [[\fR and \fB]]\fR
888 are modified appropriately to affect s-expressions and functions.
890 Default: nolist Type: toggle
892 All printed lines have the <tab> and <nl> characters displayed visually.
894 Default: magic Type: toggle
896 Enable the metacharacters for matching. These include \fB. * < > [string]
897 [^string]\fR and \fB[<chr>-<chr>]\fR.
899 Default: nonu Type: toggle
901 Each line is displayed with its line number.
903 Default: open Type: toggle
905 When set, prevents entering open or visual modes from ex or edit.
906 Not of interest from vi.
908 Default: opt Type: toggle
910 Basically of use only when using the \fBex\fR capabilities. This
911 option prevents automatic <cr>s from taking place,
912 and speeds up output of indented lines,
913 at the expense of losing typeahead on some versions of UNIX.
914 .IP paragraphs\ para 16
915 Default: para=IPLPPPQPP\ bp Type: string
917 Each pair of characters in the string indicate \fBnroff\fR macros
918 which are to be treated as the beginning of a paragraph for the
919 \fB{\fR and \fB}\fR commands. The default string is for the \fB-ms\fR
920 and \fB-mm\fR macros.
921 To indicate one letter \fBnroff\fR macros, such as \fB.P\fR or \fB.H\fR,
922 quote a space in for the second character position. For example:
925 :set paragraphs=P\e bp<nl>
927 would cause \fBvi\fR to consider \fB.P\fR and \fB.bp\fR as paragraph
930 Default: prompt Type: toggle
934 command mode the prompt character \fB:\fR will be printed when
935 \fBex\fR is waiting for a command. This is not of interest from vi.
937 Default: noredraw Type: toggle
939 On dumb terminals, force the screen to always be up to date,
940 by sending great amounts of output. Useful only at high speeds.
942 Default: report=5 Type: numeric
944 This sets the threshold for the number of lines modified. When
945 more than this number of lines are modified, removed, or yanked,
946 \fBvi\fR will report the number of lines changed at the bottom of
949 Default: scroll={1/2 window} Type: numeric
951 This is the number of lines that the screen scrolls up or down when
952 using the <^U> and <^D> commands.
954 Default: sections=SHNHH HU Type: string
956 Each two character pair of this string specify \fBnroff\fR macro names
957 which are to be treated as the beginning of a section by the
958 \fB]]\fR and \fB[[\fR commands. The default string is for the \fB-ms\fR
959 and \fB-mm\fR macros.
960 To enter one letter \fBnroff\fR macros, use a quoted space as the
962 See \fBparagraphs\fR for a fuller explanation.
964 Default: sh=from environment SHELL or /bin/sh Type: string
966 This is the name of the \fBsh\fR to be used for "escaped" commands.
967 .IP shiftwidth\ sw 16
968 Default: sw=8 Type: numeric
970 This is the number of spaces that a <^T> or <^D> will move over for
971 indenting, and the amount < and > shift by.
973 Default: nosm Type: toggle
975 When a \fB)\fR or \fB}\fR is typed, show the matching \fB(\fR or \fB{\fR
976 by moving the cursor to it for one second if it is on the current screen.
977 .IP slowopen\ slow 16
978 Default: terminal dependent Type: toggle
980 On terminals that are slow and unintelligent, this option prevents the
981 updating of the screen some of the time to improve speed.
983 Default: ts=8 Type: numeric
985 <tab>s are expanded to boundaries that are multiples of this value.
987 Default: tl=0 Type: numeric
989 If nonzero, tag names are only significant to this many characters.
991 Default: (from environment \fBTERM\fP, else dumb) Type: string
993 This is the terminal and controls the visual displays. It cannot be
994 changed when in "visual" mode,
995 you have to Q to command mode, type a
996 set term command, and do ``vi.'' to get back into visual.
997 Or exit vi, fix $TERM, and reenter.
998 The definitions that drive a particular
999 terminal type are found in the file \fB/etc/termcap\fR.
1001 Default: terse Type: toggle
1003 When set, the error diagnostics are short.
1005 Default: warn Type: toggle
1007 The user is warned if she/he tries to escape to
1008 the shell without writing out the current changes.
1010 Default: window={8 at 600 baud or less, 16 at 1200 baud, and screen
1011 size \- 1 at 2400 baud or more} Type: numeric
1013 This is the number of lines in the window whenever \fBvi\fR must redraw
1014 an entire screen. It is useful to make this size smaller if you are
1016 .IP w300,\ w1200,\ w9600
1018 These set window, but only within the corresponding speed ranges.
1019 They are useful in an EXINIT to fine tune window sizes.
1024 causes a 4 lines window at speed up to 600 baud, a 12 line window at 1200
1025 baud, and a full screen (the default) at over 1200 baud.
1027 Default: ws Type: toggle
1029 Searches will wrap around the end of the file when is option is set. When
1030 it is off, the search will terminate when it reaches the end or the
1031 beginning of the file.
1032 .IP wrapmargin\ wm 16
1033 Default: wm=0 Type: numeric
1035 \fBVi\fR will automatically insert a <nl> when it finds a natural
1036 break point (usually a <sp> between words) that occurs within
1037 "wm" spaces of the right margin.
1038 Therefore with "wm=0" the option is off. Setting it to 10 would
1039 mean that any time you are within 10 spaces of the right margin
1040 \fBvi\fR would be looking for a <sp> or <tab> which it could
1041 replace with a <nl>. This is convenient for people who forget
1042 to look at the screen while they type.
1043 (In version 3, wrapmargin behaves more like nroff, in that the
1044 boundary specified by the distance from the right edge of the screen
1045 is taken as the rightmost edge of the area where a break is allowed,
1046 instead of the leftmost edge.)
1048 Default: nowa Type: toggle
1050 \fBVi\fR normally makes a number of checks before it writes out a file.
1051 This prevents the user from inadvertently destroying a file. When the
1052 "writeany" option is enabled, \fBvi\fR no longer makes these checks.