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