nvi forgets to switch tty from ex mode on q when there are other screens
[nvi.git] / docs / vi.man / vi.1
blob8c5b5b42dfbdc2fec5b0594888dc7c61366d9257
1 .\" Copyright (c) 1994
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\" Copyright (c) 1994, 1995, 1996
4 .\"     Keith Bostic.  All rights reserved.
5 .\"
6 .\" This document may not be republished without written permission from
7 .\" Keith Bostic. 
8 .\"
9 .\" See the LICENSE file for redistribution information.
10 .\"
11 .\"     $Id: vi.1,v 8.53 2001/01/28 13:20:06 skimo Exp $ (Berkeley) $Date: 2001/01/28 13:20:06 $
12 .\"
13 .TH VI 1 "%Q%"
14 .UC
15 .SH NAME
16 ex, vi, view \- text editors
17 .SH SYNOPSIS
18 .B ex
19 [\c
20 .B -eFRrSsv\c
21 ] [\c
22 .BI -c " cmd"\c
23 ] [\c
24 .BI -t " tag"\c
25 ] [\c
26 .BI -w " size"\c
27 ] [file ...]
28 .br
29 .B vi
30 [\c
31 .B -eFlRrSv\c
32 ] [\c
33 .BI -c " cmd"\c
34 ] [\c
35 .BI -t " tag"\c
36 ] [\c
37 .BI -w " size"\c
38 ] [file ...]
39 .br
40 .B view
41 [\c
42 .B -eFRrSv\c
43 ] [\c
44 .BI -c " cmd"\c
45 ] [\c
46 .BI -t " tag"\c
47 ] [\c
48 .BI -w " size"\c
49 ] [file ...]
50 .SH LICENSE
51 The vi program is freely redistributable.  You are welcome to copy,
52 modify and share it with others under the conditions listed in the
53 LICENSE file.  If any company (not individual!) finds vi sufficiently
54 useful that you would have purchased it, or if any company wishes to
55 redistribute it, contributions to the authors would be appreciated.
56 .SH DESCRIPTION
57 .I \&Vi
58 is a screen oriented text editor.
59 .I \&Ex
60 is a line-oriented text editor.
61 .I \&Ex
62 and
63 .I \&vi
64 are different interfaces to the same program,
65 and it is possible to switch back and forth during an edit session.
66 .I View
67 is the equivalent of using the
68 .B \-R
69 (read-only) option of
70 .IR \&vi .
71 .PP
72 This manual page is the one provided with the
73 .I nex/nvi
74 versions of the
75 .I ex/vi
76 text editors.
77 .I Nex/nvi
78 are intended as bug-for-bug compatible replacements for the original
79 Fourth Berkeley Software Distribution (4BSD)
80 .I \&ex
81 and
82 .I \&vi
83 programs.
84 For the rest of this manual page,
85 .I nex/nvi
86 is used only when it's necessary to distinguish it from the historic
87 implementations of
88 .IR ex/vi .
89 .PP
90 This manual page is intended for users already familiar with
91 .IR ex/vi .
92 Anyone else should almost certainly read a good tutorial on the
93 editor before this manual page.
94 If you're in an unfamiliar environment, and you absolutely have to
95 get work done immediately, read the section after the options
96 description, entitled ``Fast Startup''.
97 It's probably enough to get you going.
98 .PP
99 The following options are available:
101 .B \-c
102 Execute
103 .B cmd
104 immediately after starting the edit session.
105 Particularly useful for initial positioning in the file, however
106 .B cmd
107 is not limited to positioning commands.
108 This is the POSIX 1003.2 interface for the historic ``+cmd'' syntax.
109 .I Nex/nvi
110 supports both the old and new syntax.
112 .B \-e
113 Start editing in ex mode, as if the command name were
114 .IR \&ex .
116 .B \-F
117 Don't copy the entire file when first starting to edit.
118 (The default is to make a copy in case someone else modifies
119 the file during your edit session.)
121 .B \-l
122 Start editing with the lisp and showmatch options set.
124 .B \-R
125 Start editing in read-only mode, as if the command name was
126 .IR view ,
127 or the
128 .B readonly
129 option was set.
131 .B \-r
132 Recover the specified files, or, if no files are specified,
133 list the files that could be recovered.
134 If no recoverable files by the specified name exist,
135 the file is edited as if the
136 .B \-r
137 option had not been specified.
139 .B \-S
140 Run with the
141 .B secure
142 edit option set, disallowing all access to external programs.
144 .B \-s
145 Enter batch mode; applicable only to
146 .I \&ex
147 edit sessions.
148 Batch mode is useful when running
149 .I \&ex
150 scripts.
151 Prompts, informative messages and other user oriented message
152 are turned off,
153 and no startup files or environmental variables are read.
154 This is the POSIX 1003.2 interface for the historic ``\-'' argument.
155 .I \&Nex/nvi
156 supports both the old and new syntax.
158 .B \-t
159 Start editing at the specified tag.
160 (See
161 .IR ctags (1)).
163 .B \-w
164 Set the initial window size to the specified number of lines.
166 .B \-v
167 Start editing in vi mode, as if the command name was
168 .I \&vi
170 .IR view .
172 Command input for
173 .I ex/vi
174 is read from the standard input.
175 In the
176 .I \&vi
177 interface, it is an error if standard input is not a terminal.
178 In the
179 .I \&ex
180 interface, if standard input is not a terminal,
181 .I \&ex
182 will read commands from it regardless, however, the session will be a
183 batch mode session, exactly as if the
184 .B \-s
185 option had been specified.
187 .I Ex/vi
188 exits 0 on success, and greater than 0 if an error occurs.
189 .SH FAST STARTUP
190 This section will tell you the minimum amount that you need to
191 do simple editing tasks using
192 .IR \&vi .
193 If you've never used any screen editor before, you're likely to have
194 problems even with this simple introduction.
195 In that case you should find someone that already knows
196 .I \&vi
197 and have them walk you through this section.
199 .I \&Vi
200 is a screen editor.
201 This means that it takes up almost the entire screen, displaying part
202 of the file on each screen line, except for the last line of the screen.
203 The last line of the screen is used for you to give commands to
204 .IR \&vi ,
205 and for
206 .I \&vi
207 to give information to you.
209 The other fact that you need to understand is that
210 .I \&vi
211 is a modeful editor, i.e. you are either entering text or you
212 are executing commands, and you have to be in the right mode
213 to do one or the other.
214 You will be in command mode when you first start editing a file.
215 There are commands that switch you into input mode.
216 There is only one key that takes you out of input mode,
217 and that is the <escape> key.
218 (Key names are written using less-than and greater-than signs, e.g.
219 <escape> means the ``escape'' key, usually labeled ``esc'' on your
220 terminal's keyboard.)
221 If you're ever confused as to which mode you're in,
222 keep entering the <escape> key until
223 .I \&vi
224 beeps at you.
225 (Generally,
226 .I \&vi
227 will beep at you if you try and do something that's not allowed.
228 It will also display error messages.)
230 To start editing a file, enter the command ``vi file_name<carriage-return>''.
231 The command you should enter as soon as you start editing is
232 ``:set verbose showmode<carriage-return>''.
233 This will make the editor give you verbose error messages and display
234 the current mode at the bottom of the screen.
236 The commands to move around the file are:
238 .B h
239 Move the cursor left one character.
241 .B j
242 Move the cursor down one line.
244 .B k
245 Move the cursor up one line.
247 .B l
248 Move the cursor right one character.
250 .B <cursor-arrows>
251 The cursor arrow keys should work, too.
253 .B /text<carriage-return>
254 Search for the string ``text'' in the file,
255 and move the cursor to its first character.
257 The commands to enter new text are:
259 .B a
260 Append new text,
261 .I after
262 the cursor.
264 .B i
265 Insert new text,
266 .I before
267 the cursor.
269 .B o
270 Open a new line below the line the cursor is on, and start
271 entering text.
273 .B O
274 Open a new line above the line the cursor is on, and start
275 entering text.
277 .B <escape>
278 Once you've entered input mode using the one of the
279 .BR \&a ,
280 .BR \&i ,
281 .BR \&O
282 or 
283 .B \&o
284 commands, use
285 .B <escape>
286 to quit entering text and return to command mode.
288 The commands to copy text are:
290 .B yy
291 Copy the line the cursor is on.
293 .B p
294 Append the copied line after the line the cursor is on.
296 The commands to delete text are:
298 .B dd
299 Delete the line the cursor is on.
301 .B x
302 Delete the character the cursor is on.
304 The commands to write the file are:
306 .B :w<carriage-return>
307 Write the file back to the file with the name that you originally used
308 as an argument on the
309 .I \&vi
310 command line.
312 .B ":w file_name<carriage-return>"
313 Write the file back to the file with the name ``file_name''.
315 The commands to quit editing and exit the editor are:
317 .B :q<carriage-return>
318 Quit editing and leave vi (if you've modified the file, but not
319 saved your changes,
320 .I \&vi
321 will refuse to quit).
323 .B :q!<carriage-return>
324 Quit, discarding any modifications that you may have made.
326 One final caution.
327 Unusual characters can take up more than one column on the screen,
328 and long lines can take up more than a single screen line.
329 The above commands work on ``physical'' characters and lines,
330 i.e. they affect the entire line no matter how many screen lines it
331 takes up and the entire character no matter how many screen columns
332 it takes up.
333 .SH VI COMMANDS
334 The following section describes the commands available in the command
335 mode of the
336 .I \&vi
337 editor.
338 In each entry below, the tag line is a usage synopsis for the command
339 character.
342 .B "[count] <control-A>"
343 Search forward
344 .I count
345 times for the current word.
347 .B "[count] <control-B>"
348 Page backwards
349 .I count
350 screens.
352 .B "[count] <control-D>"
353 Scroll forward
354 .I count
355 lines.
357 .B "[count] <control-E>"
358 Scroll forward
359 .I count
360 lines, leaving the current line and column as is, if possible.
362 .B "[count] <control-F>"
363 Page forward
364 .I count
365 screens.
367 .B "<control-G>"
368 Display the file information.
370 .B "<control-H>"
372 .B "[count] h"
373 Move the cursor back
374 .I count
375 characters in the current line.
377 .B "[count] <control-J>"
379 .B "[count] <control-N>"
381 .B "[count] j"
382 Move the cursor down
383 .I count
384 lines without changing the current column.
386 .B "<control-L>"
388 .B "<control-R>"
389 Repaint the screen.
391 .B "[count] <control-M>"
393 .B "[count] +"
394 Move the cursor down
395 .I count
396 lines to the first nonblank character of that line.
398 .B "[count] <control-P>"
400 .B "[count] k"
401 Move the cursor up
402 .I count
403 lines, without changing the current column.
405 .B "<control-T>"
406 Return to the most recent tag context.
408 .B "<control-U>"
409 Scroll backwards
410 .I count
411 lines.
413 .B "<control-W>"
414 Switch to the next lower screen in the window, or, to the first
415 screen if there are no lower screens in the window.
417 .B "<control-Y>"
418 Scroll backwards
419 .I count
420 lines, leaving the current line and column as is, if possible.
422 .B "<control-Z>"
423 Suspend the current editor session.
425 .B "<escape>"
426 Execute
427 .I \&ex
428 commands or cancel partial commands.
430 .B "<control-]>"
431 Push a tag reference onto the tag stack.
433 .B "<control-^>"
434 Switch to the most recently edited file.
436 .B "[count] <space>"
438 .B "[count] l"
439 Move the cursor forward
440 .I count
441 characters without changing the current line.
443 .B "[count] ! motion shell-argument(s)"
444 Replace text with results from a shell command.
446 .B "[count] # #|+|-"
447 Increment or decrement the cursor number.
449 .B "[count] $"
450 Move the cursor to the end of a line.
452 .B "%"
453 Move to the matching character.
455 .B "&"
456 Repeat the previous substitution command on the current line.
458 .B "'<character>"
460 .B "`<character>"
461 Return to a context marked by the character
462 .IR <character> .
464 .B "[count] ("
465 Back up
466 .I count
467 sentences.
469 .B "[count] )"
470 Move forward
471 .I count
472 sentences.
474 .B "[count] ,"
475 Reverse find character
476 .I count
477 times.
479 .B "[count] -"
480 Move to first nonblank of the previous line,
481 .I count
482 times.
484 .B "[count] ."
485 Repeat the last
486 .I \&vi
487 command that modified text.
489 .B "/RE<carriage-return>"
491 .B "/RE/ [offset]<carriage-return>"
493 .B "?RE<carriage-return>"
495 .B "?RE? [offset]<carriage-return>"
497 .B "N"
499 .B "n"
500 Search forward or backward for a regular expression.
502 .B "0"
503 Move to the first character in the current line.
505 .B ":"
506 Execute an ex command.
508 .B "[count] ;"
509 Repeat the last character find
510 .I count
511 times.
513 .B "[count] < motion"
515 .B "[count] > motion"
516 Shift lines left or right.
518 .B "@ buffer"
519 Execute a named buffer.
521 .B "[count] A"
522 Enter input mode, appending the text after the end of the line.
524 .B "[count] B"
525 Move backwards
526 .I count
527 bigwords.
529 .B "[buffer] [count] C"
530 Change text from the current position to the end-of-line.
532 .B "[buffer] D"
533 Delete text from the current position to the end-of-line.
535 .B "[count] E"
536 Move forward
537 .I count
538 end-of-bigwords.
540 .B "[count] F <character>"
541 Search
542 .I count
543 times backward through the current line for
544 .IR <character> .
546 .B "[count] G"
547 Move to line
548 .IR count ,
549 or the last line of the file if
550 .I count
551 not specified.
553 .B "[count] H"
554 Move to the screen line
555 .I "count - 1"
556 lines below the top of the screen.
558 .B "[count] I"
559 Enter input mode, inserting the text at the beginning of the line.
561 .B "[count] J"
562 Join lines.
564 .B "[count] L"
565 Move to the screen line
566 .I "count - 1"
567 lines above the bottom of the screen.
569 .B " M"
570 Move to the screen line in the middle of the screen.
572 .B "[count] O"
573 Enter input mode, appending text in a new line above the current line.
575 .B "[buffer] P"
576 Insert text from a buffer.
578 .B "Q"
579 Exit
580 .I \&vi
581 (or visual) mode and switch to
582 .I \&ex
583 mode.
585 .B "[count] R"
586 Enter input mode, replacing the characters in the current line.
588 .B "[buffer] [count] S"
589 Substitute
590 .I count
591 lines.
593 .B "[count] T <character>"
594 Search backwards,
595 .I count
596 times,
597 through the current line for the character
598 .I after
599 the specified
600 .IR <character> .
602 .B "U"
603 Restore the current line to its state before the cursor last
604 moved to it.
606 .B "[count] W"
607 Move forward
608 .I count
609 bigwords.
611 .B "[buffer] [count] X"
612 Delete
613 .I count
614 characters before the cursor.
616 .B "[buffer] [count] Y"
617 Copy (or ``yank'')
618 .I count
619 lines into the specified buffer.
621 .B "ZZ"
622 Write the file and exit
623 .IR \&vi .
625 .B "[count] [["
626 Back up
627 .I count
628 section boundaries.
630 .B "[count] ]]"
631 Move forward
632 .I count
633 section boundaries.
635 .B "\&^"
636 Move to first nonblank character on the current line.
638 .B "[count] _"
639 Move down
640 .I "count - 1"
641 lines, to the first nonblank character.
643 .B "[count] a"
644 Enter input mode, appending the text after the cursor.
646 .B "[count] b"
647 Move backwards
648 .I count
649 words.
651 .B "[buffer] [count] c motion"
652 Change a region of text.
654 .B "[buffer] [count] d motion"
655 Delete a region of text.
657 .B "[count] e"
658 Move forward
659 .I count
660 end-of-words.
662 .B "[count] f<character>"
663 Search forward,
664 .I count
665 times, through the rest of the current line for
666 .IR <character> .
668 .B "[count] i"
669 Enter input mode, inserting the text before the cursor.
671 .B "m <character>"
672 Save the current context (line and column) as
673 .IR <character> .
675 .B "[count] o"
676 Enter input mode, appending text in a new line under the current line.
678 .B "[buffer] p"
679 Append text from a buffer.
681 .B "[count] r <character>"
682 Replace
683 .I count
684 characters.
686 .B "[buffer] [count] s"
687 Substitute
688 .I count
689 characters in the current line starting with the current character.
691 .B "[count] t <character>"
692 Search forward,
693 .I count
694 times, through the current line for the character immediately
695 .I before
696 .IR <character> .
698 .B "u"
699 Undo the last change made to the file.
701 .B "[count] w"
702 Move forward
703 .I count
704 words.
706 .B "[buffer] [count] x"
707 Delete
708 .I count
709 characters.
711 .B "[buffer] [count] y motion"
712 Copy (or ``yank'')
713 a text region specified by the
714 .I count
715 and motion into a buffer.
717 .B "[count1] z [count2] -|.|+|^|<carriage-return>"
718 Redraw, optionally repositioning and resizing the screen.
720 .B "[count] {"
721 Move backward
722 .I count
723 paragraphs.
725 .B "[count] |"
726 Move to a specific
727 .I column
728 position on the current line.
730 .B "[count] }"
731 Move forward
732 .I count
733 paragraphs.
735 .B "[count] ~"
736 Reverse the case of the next
737 .I count
738 character(s).
740 .B "[count] ~ motion"
741 Reverse the case of the characters in a text region specified by the
742 .I count
744 .IR motion .
746 .B "<interrupt>"
747 Interrupt the current operation.
748 .SH VI TEXT INPUT COMMANDS
749 The following section describes the commands available in the text
750 input mode of the
751 .I \&vi
752 editor.
755 .B "<nul>"
756 Replay the previous input.
758 .B "<control-D>"
759 Erase to the previous
760 .B shiftwidth
761 column boundary.
763 .B "^<control-D>"
764 Erase all of the autoindent characters, and reset the autoindent level.
766 .B "0<control-D>"
767 Erase all of the autoindent characters.
769 .B "<control-T>"
770 Insert sufficient
771 .I <tab>
773 .I <space>
774 characters to move forward to the next
775 .B shiftwidth
776 column boundary.
778 .B "<erase>
780 .B "<control-H>"
781 Erase the last character.
783 .B "<literal next>"
784 Quote the next character.
786 .B "<escape>
787 Resolve all text input into the file, and return to command mode.
789 .B "<line erase>"
790 Erase the current line.
792 .B "<control-W>"
794 .B "<word erase>"
795 Erase the last word.
796 The definition of word is dependent on the
797 .B altwerase
799 .B ttywerase
800 options.
802 .B "<control-X>[0-9A-Fa-f]+"
803 Insert a character with the specified hexadecimal value into the text.
805 .B "<interrupt>"
806 Interrupt text input mode, returning to command mode.
807 .SH EX COMMANDS
808 The following section describes the commands available in the
809 .I \&ex
810 editor.
811 In each entry below, the tag line is a usage synopsis for the command.
814 .B "<end-of-file>"
815 Scroll the screen.
817 .B "! argument(s)"
819 .B "[range]! argument(s)"
820 Execute a shell command, or filter lines through a shell command.
822 .B \&"
823 A comment.
825 .B "[range] nu[mber] [count] [flags]"
827 .B "[range] # [count] [flags]"
828 Display the selected lines, each preceded with its line number.
830 .B "@ buffer"
832 .B "* buffer"
833 Execute a buffer.
835 .B "[line] a[ppend][!]"
836 The input text is appended after the specified line.
838 .B "[range] c[hange][!] [count]"
839 The input text replaces the specified range.
841 .B "cs[cope] add | find | help | kill | reset"
842 Execute a Cscope command.
844 .B "[range] d[elete] [buffer] [count] [flags]"
845 Delete the lines from the file.
847 .B "di[splay] b[uffers] | c[onnections] | s[creens] | t[ags]"
848 Display buffers, Cscope connections, screens or tags.
850 .B "[Ee][dit][!] [+cmd] [file]"
852 .B "[Ee]x[!] [+cmd] [file]"
853 Edit a different file.
855 .B "exu[sage] [command]"
856 Display usage for an
857 .I \&ex
858 command.
860 .B "f[ile] [file]"
861 Display and optionally change the file name.
863 .B "[Ff]g [name]"
864 .I \&Vi
865 mode only.
866 Foreground the specified screen.
868 .B "[range] g[lobal] /pattern/ [commands]"
870 .B "[range] v /pattern/ [commands]"
871 Apply commands to lines matching (or not matching) a pattern.
873 .B "he[lp]"
874 Display a help message.
876 .B "[line] i[nsert][!]"
877 The input text is inserted before the specified line.
879 .B "[range] j[oin][!] [count] [flags]"
880 Join lines of text together.
882 .B "[range] l[ist] [count] [flags]"
883 Display the lines unambiguously.
885 .B "map[!] [lhs rhs]"
886 Define or display maps (for
887 .I \&vi
888 only).
890 .B "[line] ma[rk] <character>"
892 .B "[line] k <character>"
893 Mark the line with the mark
894 .IR <character> .
896 .B "[range] m[ove] line"
897 Move the specified lines after the target line.
899 .B "mk[exrc][!] file"
900 Write the abbreviations, editor options and maps to the specified
901 file.
903 .B "[Nn][ext][!] [file ...]"
904 Edit the next file from the argument list.
906 .B "[line] o[pen] /pattern/ [flags]"
907 Enter open mode.
909 .B "pre[serve]"
910 Save the file in a form that can later be recovered using the
911 .I \&ex
912 .B \-r
913 option.
915 .B "[Pp]rev[ious][!]"
916 Edit the previous file from the argument list.
918 .B "[range] p[rint] [count] [flags]"
919 Display the specified lines.
921 .B "[line] pu[t] [buffer]"
922 Append buffer contents to the current line.
924 .B "q[uit][!]"
925 End the editing session.
927 .B "[line] r[ead][!] [file]"
928 Read a file.
930 .B "rec[over] file"
931 Recover
932 .I file
933 if it was previously saved.
935 .B "res[ize] [+|-]size"
936 .I \&Vi
937 mode only.
938 Grow or shrink the current screen.
940 .B "rew[ind][!]"
941 Rewind the argument list.
943 .B "se[t] [option[=[value]] ...] [nooption ...] [option? ...] [all]"
944 Display or set editor options.
946 .B "sh[ell]"
947 Run a shell program.
949 .B "so[urce] file"
950 Read and execute
951 .I \&ex
952 commands from a file.
954 .B "[range] s[ubstitute] [/pattern/replace/] [options] [count] [flags]"
956 .B "[range] & [options] [count] [flags]"
958 .B "[range] ~ [options] [count] [flags]"
959 Make substitutions.
961 .B "su[spend][!]"
963 .B "st[op][!]"
965 .B <suspend>
966 Suspend the edit session.
968 .B "[Tt]a[g][!] tagstring"
969 Edit the file containing the specified tag.
971 .B "tagn[ext][!]"
972 Edit the file containing the next context for the current tag.
974 .B "tagp[op][!] [file | number]"
975 Pop to the specified tag in the tags stack.
977 .B "tagp[rev][!]"
978 Edit the file containing the previous context for the current tag.
980 .B "unm[ap][!] lhs"
981 Unmap a mapped string.
983 .B "ve[rsion]"
984 Display the version of the
985 .I \&ex/vi
986 editor.
988 .B "[line] vi[sual] [type] [count] [flags]"
989 .I \&Ex
990 mode only.
991 Enter
992 .IR \&vi .
994 .B "[Vi]i[sual][!] [+cmd] [file]"
995 .I \&Vi
996 mode only.
997 Edit a new file.
999 .B "viu[sage] [command]"
1000 Display usage for a
1001 .I \&vi
1002 command.
1004 .B "[range] w[rite][!] [>>] [file]"
1006 .B "[range] w[rite] [!] [file]"
1008 .B "[range] wn[!] [>>] [file]"
1010 .B "[range] wq[!] [>>] [file]"
1011 Write the file.
1013 .B "[range] x[it][!] [file]"
1014 Write the file if it has been modified.
1016 .B "[range] ya[nk] [buffer] [count]"
1017 Copy the specified lines to a buffer.
1019 .B "[line] z [type] [count] [flags]"
1020 Adjust the window.
1021 .SH SET OPTIONS
1022 There are a large number of options that may be set (or unset) to
1023 change the editor's behavior.
1024 This section describes the options, their abbreviations and their
1025 default values.
1027 In each entry below, the first part of the tag line is the full name
1028 of the option, followed by any equivalent abbreviations.
1029 The part in square brackets is the default value of the option.
1030 Most of the options are boolean, i.e. they are either on or off,
1031 and do not have an associated value.
1033 Options apply to both
1034 .I \&ex
1036 .I \&vi
1037 modes, unless otherwise specified.
1040 .B "altwerase [off]"
1041 .I \&Vi
1042 only.
1043 Select an alternate word erase algorithm.
1045 .B "autoindent, ai [off]"
1046 Automatically indent new lines.
1048 .B "autoprint, ap [off]"
1049 .I \&Ex
1050 only.
1051 Display the current line automatically.
1053 .B "autowrite, aw [off]"
1054 Write modified files automatically when changing files.
1055 .\" I cannot get a double quote to print between the square brackets
1056 .\" to save my life.  The ONLY way I've been able to get this to work
1057 .\" is with the .tr command.
1058 .tr Q"
1059 .ds ms backup [QQ]
1061 .B "\*(ms"
1062 .tr QQ
1063 Backup files before they are overwritten.
1065 .B "beautify, bf [off]"
1066 Discard control characters.
1068 .B "cdpath [environment variable CDPATH, or current directory]"
1069 The directory paths used as path prefixes for the
1070 .B cd
1071 command.
1073 .B "cedit [no default]"
1074 Set the character to edit the colon command-line history.
1076 .B "columns, co [80]"
1077 Set the number of columns in the screen.
1079 .B "comment [off]"
1080 .I \&Vi
1081 only.
1082 Skip leading comments in shell, C and C++ language files.
1084 .B "directory, dir [environment variable TMPDIR, or /tmp]"
1085 The directory where temporary files are created.
1087 .B "edcompatible, ed [off]"
1088 Remember the values of the ``c'' and ``g'' suffices to the
1089 .B substitute
1090 commands, instead of initializing them as unset for each new
1091 command.
1093 .B "errorbells, eb [off]"
1094 .I \&Ex
1095 only.
1096 Announce error messages with a bell.
1098 .B "exrc, ex [off]"
1099 Read the startup files in the local directory.
1101 .B "extended [off]"
1102 Regular expressions are extended (i.e.
1103 .IR egrep (1)\-\c
1104 style) expressions.
1106 .B "filec [no default]"
1107 Set the character to perform file path completion on the colon
1108 command line.
1110 .B "flash [on]"
1111 Flash the screen instead of beeping the keyboard on error.
1113 .B "hardtabs, ht [8]"
1114 Set the spacing between hardware tab settings.
1116 .B "iclower [off]"
1117 Makes all Regular Expressions case-insensitive,
1118 as long as an upper-case letter does not appear in the search string.
1120 .B "ignorecase, ic [off]"
1121 Ignore case differences in regular expressions.
1123 .B "keytime [6]"
1124 The 10th's of a second
1125 .I ex/vi
1126 waits for a subsequent key to complete a key mapping.
1128 .B "leftright [off]"
1129 .I \&Vi
1130 only.
1131 Do left-right scrolling.
1133 .B "lines, li [24]"
1134 .I \&Vi
1135 only.
1136 Set the number of lines in the screen.
1138 .B "lisp [off]"
1139 .I \&Vi
1140 only.
1141 Modify various search commands and options to work with Lisp.
1142 .I "This option is not yet implemented."
1144 .B "list [off]"
1145 Display lines in an unambiguous fashion.
1147 .B "lock [on]"
1148 Attempt to get an exclusive lock on any file being edited,
1149 read or written.
1151 .B "magic [on]"
1152 Treat certain characters specially in regular expressions.
1154 .B "matchtime [7]"
1155 .I \&Vi
1156 only.
1157 The 10th's of a second
1158 .I ex/vi
1159 pauses on the matching character when the
1160 .B showmatch
1161 option is set.
1163 .B "mesg [on]"
1164 Permit messages from other users.
1166 .B "modelines, modeline [off]"
1167 Read the first and last few lines of each file for
1168 .I ex
1169 commands.
1170 .I "This option will never be implemented."
1171 .\" I cannot get a double quote to print between the square brackets
1172 .\" to save my life.  The ONLY way I've been able to get this to work
1173 .\" is with the .tr command.
1174 .tr Q"
1175 .ds ms noprint [QQ]
1177 .B "\*(ms"
1178 .tr QQ
1179 Characters that are never handled as printable characters.
1181 .B "number, nu [off]"
1182 Precede each line displayed with its current line number.
1184 .B "octal [off]"
1185 Display unknown characters as octal numbers, instead of the default
1186 hexadecimal.
1188 .B "open [on]"
1189 .I \&Ex
1190 only.
1191 If this option is not set, the
1192 .B open
1194 .B visual
1195 commands are disallowed.
1197 .B "optimize, opt [on]"
1198 .I \&Vi
1199 only.
1200 Optimize text throughput to dumb terminals.
1201 .I "This option is not yet implemented."
1203 .B "paragraphs, para [IPLPPPQPP LIpplpipbp]"
1204 .I \&Vi
1205 only.
1206 Define additional paragraph boundaries for the
1207 .B \&{
1209 .B \&}
1210 commands.
1212 .B "path []"
1213 Define additional directories to search for files being edited.
1214 .\" I cannot get a double quote to print between the square brackets
1215 .\" to save my life.  The ONLY way I've been able to get this to work
1216 .\" is with the .tr command.
1217 .tr Q"
1218 .ds ms print [QQ]
1220 .B "\*(ms"
1221 .tr QQ
1222 Characters that are always handled as printable characters.
1224 .B "prompt [on]"
1225 .I \&Ex
1226 only.
1227 Display a command prompt.
1229 .B "readonly, ro [off]"
1230 Mark the file and session as read-only.
1232 .B "recdir [/var/tmp/vi.recover]"
1233 The directory where recovery files are stored.
1235 .B "redraw, re [off]"
1236 .I \&Vi
1237 only.
1238 Simulate an intelligent terminal on a dumb one.
1239 .I "This option is not yet implemented."
1241 .B "remap [on]"
1242 Remap keys until resolved.
1244 .B "report [5]"
1245 Set the number of lines about which the editor reports changes
1246 or yanks.
1248 .B "ruler [off]"
1249 .I \&Vi
1250 only.
1251 Display a row/column ruler on the colon command line.
1253 .B "scroll, scr [window / 2]"
1254 Set the number of lines scrolled.
1256 .B "searchincr [off]"
1257 Makes the
1258 .B \&/
1260 .B \&?
1261 commands incremental.
1263 .B "sections, sect [NHSHH HUnhsh]"
1264 .I \&Vi
1265 only.
1266 Define additional section boundaries for the
1267 .B \&[[
1269 .B \&]]
1270 commands.
1272 .B "secure [off]"
1273 Turns off all access to external programs.
1275 .B "shell, sh [environment variable SHELL, or /bin/sh]"
1276 Select the shell used by the editor.
1277 .\" I cannot get a double quote to print between the square brackets
1278 .\" to save my life.  The ONLY way I've been able to get this to work
1279 .\" is with the .tr command.
1280 .tr Q"
1281 .ds ms shellmeta [~{[*?$`'Q\e]
1283 .B "\*(ms"
1284 .tr QQ
1285 Set the meta characters checked to determine if file name expansion
1286 is necessary.
1288 .B "shiftwidth, sw [8]"
1289 Set the autoindent and shift command indentation width.
1291 .B "showmatch, sm [off]"
1292 .I \&Vi
1293 only.
1294 Note matching ``{'' and ``('' for ``}'' and ``)'' characters.
1296 .B "showmode, smd [off]"
1297 .I \&Vi
1298 only.
1299 Display the current editor mode and a ``modified'' flag.
1301 .B "sidescroll [16]"
1302 .I \&Vi
1303 only.
1304 Set the amount a left-right scroll will shift.
1306 .B "slowopen, slow [off]"
1307 Delay display updating during text input.
1308 .I "This option is not yet implemented."
1310 .B "sourceany [off]"
1311 Read startup files not owned by the current user.
1312 .I "This option will never be implemented."
1314 .B "tabstop, ts [8]"
1315 This option sets tab widths for the editor display.
1317 .B "taglength, tl [0]"
1318 Set the number of significant characters in tag names.
1320 .B "tags, tag [tags /var/db/libc.tags /sys/kern/tags]"
1321 Set the list of tags files.
1323 .B "term, ttytype, tty [environment variable TERM]"
1324 Set the terminal type.
1326 .B "terse [off]"
1327 This option has historically made editor messages less verbose.
1328 It has no effect in this implementation.
1330 .B "tildeop [off]"
1331 Modify the
1332 .B \&~
1333 command to take an associated motion.
1335 .B "timeout, to [on]"
1336 Time out on keys which may be mapped.
1338 .B "ttywerase [off]"
1339 .I \&Vi
1340 only.
1341 Select an alternate erase algorithm.
1343 .B "verbose [off]"
1344 .I \&Vi
1345 only.
1346 Display an error message for every error.
1348 .B "w300 [no default]"
1349 .I \&Vi
1350 only.
1351 Set the window size if the baud rate is less than 1200 baud.
1353 .B "w1200 [no default]"
1354 .I \&Vi
1355 only.
1356 Set the window size if the baud rate is equal to 1200 baud.
1358 .B "w9600 [no default]"
1359 .I \&Vi
1360 only.
1361 Set the window size if the baud rate is greater than 1200 baud.
1363 .B "warn [on]"
1364 .I \&Ex
1365 only.
1366 This option causes a warning message to the terminal if the file has
1367 been modified, since it was last written, before a
1368 .B \&!
1369 command.
1371 .B "window, w, wi [environment variable LINES]"
1372 Set the window size for the screen.
1374 .B "windowname [off]"
1375 Change the icon/window name to the current file name even if it can't
1376 be restored on editor exit.
1378 .B "wraplen, wl [0]"
1379 .I \&Vi
1380 only.
1381 Break lines automatically, the specified number of columns from the
1382 left-hand margin.
1383 If both the
1384 .B wraplen
1386 .B wrapmargin
1387 edit options are set, the
1388 .B wrapmargin
1389 value is used.
1391 .B "wrapmargin, wm [0]"
1392 .I \&Vi
1393 only.
1394 Break lines automatically, the specified number of columns from the
1395 right-hand margin.
1396 If both the
1397 .B wraplen
1399 .B wrapmargin
1400 edit options are set, the
1401 .B wrapmargin
1402 value is used.
1404 .B "wrapscan, ws [on]"
1405 Set searches to wrap around the end or beginning of the file.
1407 .B "writeany, wa [off]"
1408 Turn off file-overwriting checks.
1409 .SH "ENVIRONMENT VARIABLES
1411 .I COLUMNS
1412 The number of columns on the screen.
1413 This value overrides any system or terminal specific values.
1414 If the
1415 .I COLUMNS
1416 environmental variable is not set when
1417 .I ex/vi
1418 runs, or the
1419 .B columns
1420 option is explicitly reset by the user,
1421 .I ex/vi
1422 enters the value into the environment.
1424 .I EXINIT
1425 A list of
1426 .I \&ex
1427 startup commands, read if the variable
1428 .I NEXINIT
1429 is not set.
1431 .I HOME
1432 The user's home directory, used as the initial directory path
1433 for the startup ``$\fIHOME\fP/.nexrc'' and ``$\fIHOME\fP/.exrc''
1434 files.
1435 This value is also used as the default directory for the
1436 .I \&vi
1437 .B \&cd
1438 command.
1440 .I LINES
1441 The number of rows on the screen.
1442 This value overrides any system or terminal specific values.
1443 If the
1444 .I LINES
1445 environmental variable is not set when
1446 .I ex/vi
1447 runs, or the
1448 .B lines
1449 option is explicitly reset by the user,
1450 .I ex/vi
1451 enters the value into the environment.
1453 .I NEXINIT
1454 A list of
1455 .I \&ex
1456 startup commands.
1458 .I SHELL
1459 The user's shell of choice (see also the
1460 .B shell
1461 option).
1463 .I TERM
1464 The user's terminal type.
1465 The default is the type ``unknown''.
1466 If the
1467 .I TERM
1468 environmental variable is not set when
1469 .I ex/vi
1470 runs, or the
1471 .B term
1472 option is explicitly reset by the user,
1473 .I ex/vi
1474 enters the value into the environment.
1476 .I TMPDIR
1477 The location used to stored temporary files (see also the
1478 .B directory
1479 edit option).
1480 .SH ASYNCHRONOUS EVENTS
1482 SIGALRM
1483 .I \&Vi/ex
1484 uses this signal for periodic backups of file modifications and to
1485 display ``busy'' messages when operations are likely to take a long time.
1487 SIGHUP
1489 SIGTERM
1490 If the current buffer has changed since it was last written in its
1491 entirety, the editor attempts to save the modified file so it can
1492 be later recovered.
1493 See the
1494 .I \&vi/ex
1495 Reference manual section entitled ``Recovery'' for more information.
1497 SIGINT
1498 When an interrupt occurs,
1499 the current operation is halted,
1500 and the editor returns to the command level.
1501 If interrupted during text input,
1502 the text already input is resolved into the file as if the text
1503 input had been normally terminated.
1505 SIGWINCH
1506 The screen is resized.
1507 See the
1508 .I \&vi/ex
1509 Reference manual section entitled ``Sizing the Screen'' for more information.
1511 SIGCONT
1513 SIGQUIT
1515 SIGTSTP
1516 .I \&Vi/ex
1517 ignores these signals.
1518 .SH FILES
1520 /bin/sh
1521 The default user shell.
1523 /etc/vi.exrc
1524 System-wide vi startup file.
1526 /tmp
1527 Temporary file directory.
1529 /var/tmp/vi.recover
1530 The default recovery file directory.
1532 $HOME/.nexrc
1533 1st choice for user's home directory startup file.
1535 $HOME/.exrc
1536 2nd choice for user's home directory startup file.
1538 \&.nexrc
1539 1st choice for local directory startup file.
1541 \&.exrc
1542 2nd choice for local directory startup file.
1543 .SH SEE ALSO
1544 .IR ctags (1),
1545 .IR more (1),
1546 .IR curses (3),
1547 .IR dbopen (3)
1549 The ``Vi Quick Reference'' card.
1551 ``An Introduction to Display Editing with Vi'', found in the
1552 ``UNIX User's Manual Supplementary Documents''
1553 section of both the 4.3BSD and 4.4BSD manual sets.
1554 This document is the closest thing available to an introduction to the
1555 .I \&vi
1556 screen editor.
1558 ``Ex Reference Manual (Version 3.7)'',
1559 found in the
1560 ``UNIX User's Manual Supplementary Documents''
1561 section of both the 4.3BSD and 4.4BSD manual sets.
1562 This document is the final reference for the
1563 .I \&ex
1564 editor, as distributed in most historic 4BSD and System V systems.
1566 ``Edit: A tutorial'',
1567 found in the
1568 ``UNIX User's Manual Supplementary Documents''
1569 section of the 4.3BSD manual set.
1570 This document is an introduction to a simple version of the
1571 .I \&ex
1572 screen editor.
1574 ``Ex/Vi Reference Manual'',
1575 found in the
1576 ``UNIX User's Manual Supplementary Documents''
1577 section of the 4.4BSD manual set.
1578 This document is the final reference for the
1579 .I \&nex/nvi
1580 text editors, as distributed in 4.4BSD and 4.4BSD-Lite.
1582 .I Roff
1583 source for all of these documents is distributed with
1584 .I nex/nvi
1585 in the
1586 .I nvi/USD.doc
1587 directory of the
1588 .I nex/nvi
1589 source code.
1591 The files ``autowrite'', ``input'', ``quoting'' and ``structures''
1592 found in the
1593 .I nvi/docs/internals
1594 directory of the
1595 .I nex/nvi
1596 source code.
1597 .SH HISTORY
1599 .I nex/nvi
1600 replacements for the
1601 .I ex/vi
1602 editor first appeared in 4.4BSD.
1603 .SH STANDARDS
1604 .I \&Nex/nvi
1605 is close to IEEE Std1003.2 (``POSIX'').
1606 That document differs from historical
1607 .I ex/vi
1608 practice in several places; there are changes to be made on both sides.