]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/nvi/docs/USD.doc/vi.man/vi.1
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 .\" The vi program is freely redistributable.
9 .\" You are welcome to copy, modify and share it with others
10 .\" under the conditions listed in the LICENSE file.
11 .\" If any company (not individual!) finds vi sufficiently useful
12 .\" that you would have purchased it, or if any company wishes to
13 .\" redistribute it, contributions to the authors would be appreciated.
14 .\"
15 .\"     $Id: vi.1,v 9.0 2013/11/02 12:11:56 zy Exp $
16 .\"     $FreeBSD$
17 .\"
18 .Dd November 2, 2013
19 .Dt VI 1
20 .Os
21 .Sh NAME
22 .Nm ex , vi , view
23 .Nd text editors
24 .Sh SYNOPSIS
25 .Nm ex
26 .Op Fl FRrSsv
27 .Op Fl c Ar cmd
28 .Op Fl t Ar tag
29 .Op Fl w Ar size
30 .Op Ar
31 .Nm vi\ \&
32 .Op Fl eFRrS
33 .Op Fl c Ar cmd
34 .Op Fl t Ar tag
35 .Op Fl w Ar size
36 .Op Ar
37 .Nm view
38 .Op Fl eFrS
39 .Op Fl c Ar cmd
40 .Op Fl t Ar tag
41 .Op Fl w Ar size
42 .Op Ar
43 .Sh DESCRIPTION
44 .Nm vi
45 is a screen-oriented text editor.
46 .Nm ex
47 is a line-oriented text editor.
48 .Nm ex
49 and
50 .Nm vi
51 are different interfaces to the same program,
52 and it is possible to switch back and forth during an edit session.
53 .Nm view
54 is the equivalent of using the
55 .Fl R
56 .Pq read-only
57 option of
58 .Nm vi .
59 .Pp
60 This manual page is the one provided with the
61 .Nm nex Ns / Ns Nm nvi
62 versions of the
63 .Nm ex Ns / Ns Nm vi
64 text editors.
65 .Nm nex Ns / Ns Nm nvi
66 are intended as bug-for-bug compatible replacements for the original
67 Fourth Berkeley Software Distribution
68 .Pq 4BSD
69 .Nm ex
70 and
71 .Nm vi
72 programs.
73 For the rest of this manual page,
74 .Nm nex Ns / Ns Nm nvi
75 is used only when it's necessary to distinguish it from the historic
76 implementations of
77 .Nm ex Ns / Ns Nm vi .
78 .Pp
79 This manual page is intended for users already familiar with
80 .Nm ex Ns / Ns Nm vi .
81 Anyone else should almost certainly read a good tutorial on the
82 editor before this manual page.
83 If you're in an unfamiliar environment,
84 and you absolutely have to get work done immediately,
85 read the section after the options description, entitled
86 .Sx FAST STARTUP .
87 It's probably enough to get you going.
88 .Pp
89 The following options are available:
90 .Bl -tag -width "-w size "
91 .It Fl c Ar cmd
92 Execute
93 .Ar cmd
94 on the first file loaded.
95 Particularly useful for initial positioning in the file, although
96 .Ar cmd
97 is not limited to positioning commands.
98 This is the POSIX 1003.2 interface for the historic
99 .Dq +cmd
100 syntax.
101 .Nm nex Ns / Ns Nm nvi
102 supports both the old and new syntax.
103 .It Fl e
104 Start editing in ex mode, as if the command name were
105 .Nm ex .
106 .It Fl F
107 Don't copy the entire file when first starting to edit.
108 (The default is to make a copy in case someone else modifies
109 the file during your edit session.)
110 .\" .It Fl l
111 .\" Start editing with the lisp and showmatch options set.
112 .It Fl R
113 Start editing in read-only mode, as if the command name was
114 .Nm view ,
115 or the
116 .Cm readonly
117 option was set.
118 .It Fl r
119 Recover the specified files, or, if no files are specified,
120 list the files that could be recovered.
121 If no recoverable files by the specified name exist,
122 the file is edited as if the
123 .Fl r
124 option had not been specified.
125 .It Fl S
126 Run with the
127 .Cm secure
128 edit option set, disallowing all access to external programs.
129 .It Fl s
130 Enter batch mode; applicable only to
131 .Nm ex
132 edit sessions.
133 Batch mode is useful when running
134 .Nm ex
135 scripts.
136 Prompts, informative messages and other user oriented messages are turned off,
137 and no startup files or environment variables are read.
138 This is the POSIX 1003.2 interface for the historic
139 .Dq -
140 argument.
141 .Nm nex Ns / Ns Nm nvi
142 supports both the old and new syntax.
143 .It Fl t Ar tag
144 Start editing at the specified
145 .Ar tag
146 .Pq see Xr ctags 1 .
147 .It Fl v
148 Start editing in vi mode, as if the command name was
149 .Nm vi .
150 .It Fl w Ar size
151 Set the initial window size to the specified number of lines.
152 .El
153 .Pp
154 Command input for
155 .Nm ex Ns / Ns Nm vi
156 is read from the standard input.
157 In the
158 .Nm vi
159 interface, it is an error if standard input is not a terminal.
160 In the
161 .Nm ex
162 interface, if standard input is not a terminal,
163 .Nm ex
164 will read commands from it regardless; however, the session will be a
165 batch mode session, exactly as if the
166 .Fl s
167 option had been specified.
168 .Sh FAST STARTUP
169 This section will tell you the minimum amount that you need to
170 do simple editing tasks using
171 .Nm vi .
172 If you've never used any screen editor before,
173 you're likely to have problems even with this simple introduction.
174 In that case you should find someone that already knows
175 .Nm vi
176 and have them walk you through this section.
177 .Pp
178 .Nm vi
179 is a screen editor.
180 This means that it takes up almost the entire screen,
181 displaying part of the file on each screen line,
182 except for the last line of the screen.
183 The last line of the screen is used for you to give commands to
184 .Nm vi ,
185 and for
186 .Nm vi
187 to give information to you.
188 .Pp
189 The other fact that you need to understand is that
190 .Nm vi
191 is a modeful editor,
192 i.e., you are either entering text or you are executing commands,
193 and you have to be in the right mode to do one or the other.
194 You will be in command mode when you first start editing a file.
195 There are commands that switch you into input mode.
196 There is only one key that takes you out of input mode,
197 and that is the
198 .Aq escape
199 key.
200 .Pp
201 Key names are written using less-than and greater-than signs, e.g.,
202 .Aq escape
203 means the
204 .Dq escape
205 key, usually labeled
206 .Dq Esc
207 on your terminal's keyboard.
208 If you're ever confused as to which mode you're in,
209 keep entering the
210 .Aq escape
211 key until
212 .Nm vi
213 beeps at you.
214 Generally,
215 .Nm vi
216 will beep at you if you try and do something that's not allowed.
217 It will also display error messages.
218 .Pp
219 To start editing a file, enter the following command:
220 .Pp
221 .Dl $ vi file
222 .Pp
223 The command you should enter as soon as you start editing is:
224 .Pp
225 .Dl :set verbose showmode
226 .Pp
227 This will make the editor give you verbose error messages and display
228 the current mode at the bottom of the screen.
229 .Pp
230 The commands to move around the file are:
231 .Bl -tag -width Ds
232 .It Cm h
233 Move the cursor left one character.
234 .It Cm j
235 Move the cursor down one line.
236 .It Cm k
237 Move the cursor up one line.
238 .It Cm l
239 Move the cursor right one character.
240 .It Aq Cm cursor-arrows
241 The cursor arrow keys should work, too.
242 .It Cm / Ns text
243 Search for the string
244 .Dq text
245 in the file,
246 and move the cursor to its first character.
247 .El
248 .Pp
249 The commands to enter new text are:
250 .Bl -tag -width "<escape>"
251 .It Cm a
252 Append new text, after the cursor.
253 .It Cm i
254 Insert new text, before the cursor.
255 .It Cm o
256 Open a new line below the line the cursor is on, and start entering text.
257 .It Cm O
258 Open a new line above the line the cursor is on, and start entering text.
259 .It Aq Cm escape
260 Once you've entered input mode using one of the
261 .Cm a ,
262 .Cm i ,
263 .Cm o
264 or
265 .Cm O
266 commands, use
267 .Aq Cm escape
268 to quit entering text and return to command mode.
269 .El
270 .Pp
271 The commands to copy text are:
272 .Bl -tag -width Ds
273 .It Cm yy
274 Copy the line the cursor is on.
275 .It Cm p
276 Append the copied line after the line the cursor is on.
277 .El
278 .Pp
279 The commands to delete text are:
280 .Bl -tag -width Ds
281 .It Cm dd
282 Delete the line the cursor is on.
283 .It Cm x
284 Delete the character the cursor is on.
285 .El
286 .Pp
287 The commands to write the file are:
288 .Bl -tag -width Ds
289 .It Cm :w
290 Write the file back to the file with the name that you originally used
291 as an argument on the
292 .Nm vi
293 command line.
294 .It Cm :w Ar file_name
295 Write the file back to the file with the name
296 .Ar file_name .
297 .El
298 .Pp
299 The commands to quit editing and exit the editor are:
300 .Bl -tag -width Ds
301 .It Cm :q
302 Quit editing and leave
303 .Nm vi
304 (if you've modified the file, but not saved your changes,
305 .Nm vi
306 will refuse to quit).
307 .It Cm :q!
308 Quit, discarding any modifications that you may have made.
309 .El
310 .Pp
311 One final caution:
312 Unusual characters can take up more than one column on the screen,
313 and long lines can take up more than a single screen line.
314 The above commands work on
315 .Dq physical
316 characters and lines,
317 i.e., they affect the entire line no matter how many screen lines it takes up
318 and the entire character no matter how many screen columns it takes up.
319 .Sh REGULAR EXPRESSIONS
320 .Nm ex Ns / Ns Nm vi
321 supports regular expressions
322 .Pq REs ,
323 as documented in
324 .Xr re_format 7 ,
325 for line addresses, as the first part of the
326 .Nm ex Cm substitute ,
327 .Cm global
328 and
329 .Cm v
330 commands, and in search patterns.
331 Basic regular expressions
332 .Pq BREs
333 are enabled by default;
334 extended regular expressions
335 .Pq EREs
336 are used if the
337 .Cm extended
338 option is enabled.
339 The use of regular expressions can be largely disabled using the
340 .Cm magic
341 option.
342 .Pp
343 The following strings have special meanings in the
344 .Nm ex Ns / Ns Nm vi
345 version of regular expressions:
346 .Bl -bullet -offset 6u
347 .It
348 An empty regular expression is equivalent to the last regular expression used.
349 .It
350 .Sq \e\(la
351 matches the beginning of the word.
352 .It
353 .Sq \e\(ra
354 matches the end of the word.
355 .It
356 .Sq \(a~
357 matches the replacement part of the last
358 .Cm substitute
359 command.
360 .El
361 .Sh BUFFERS
362 A buffer is an area where commands can save changed or deleted text
363 for later use.
364 .Nm vi
365 buffers are named with a single character preceded by a double quote,
366 for example
367 .Pf \&" Ns Aq c ;
368 .Nm ex
369 buffers are the same,
370 but without the double quote.
371 .Nm nex Ns / Ns Nm nvi
372 permits the use of any character without another meaning in the position where
373 a buffer name is expected.
374 .Pp
375 All buffers are either in
376 .Em line mode
377 or
378 .Em character mode .
379 Inserting a buffer in line mode into the text creates new lines for each of the
380 lines it contains, while a buffer in character mode creates new lines for any
381 lines
382 .Em other
383 than the first and last lines it contains.
384 The first and last lines are inserted at the current cursor position, becoming
385 part of the current line.
386 If there is more than one line in the buffer,
387 the current line itself will be split.
388 All
389 .Nm ex
390 commands which store text into buffers do so in line mode.
391 The behaviour of
392 .Nm vi
393 commands depend on their associated motion command:
394 .Bl -bullet -offset 6u
395 .It
396 .Aq Cm control-A ,
397 .Cm h ,
398 .Cm l ,
399 .Cm ,\& ,
400 .Cm 0 ,
401 .Cm B ,
402 .Cm E ,
403 .Cm F ,
404 .Cm T ,
405 .Cm W ,
406 .Cm ^ ,
407 .Cm b ,
408 .Cm e ,
409 .Cm f
410 and
411 .Cm t
412 make the destination buffer character-oriented.
413 .It
414 .Cm j ,
415 .Aq Cm control-M ,
416 .Cm k ,
417 .Cm ' ,
418 .Cm - ,
419 .Cm G ,
420 .Cm H ,
421 .Cm L ,
422 .Cm M ,
423 .Cm _
424 and
425 .Cm |\&
426 make the destination buffer line-oriented.
427 .It
428 .Cm $ ,
429 .Cm % ,
430 .Cm ` ,
431 .Cm (\& ,
432 .Cm )\& ,
433 .Cm / ,
434 .Cm ?\& ,
435 .Cm [[ ,
436 .Cm ]] ,
437 .Cm {
438 and
439 .Cm }
440 make the destination buffer character-oriented, unless the starting and
441 end positions are the first and last characters on a line.
442 In that case, the buffer is line-oriented.
443 .El
444 .Pp
445 The
446 .Nm ex
447 command
448 .Cm display buffers
449 displays the current mode for each buffer.
450 .Pp
451 Buffers named
452 .Sq a
453 through
454 .Sq z
455 may be referred to using their uppercase equivalent, in which case new content
456 will be appended to the buffer, instead of replacing it.
457 .Pp
458 Buffers named
459 .Sq 1
460 through
461 .Sq 9
462 are special.
463 A region of text modified using the
464 .Cm c
465 .Pq change
466 or
467 .Cm d
468 .Pq delete
469 commands is placed into the numeric buffer
470 .Sq 1
471 if no other buffer is specified and if it meets one of the following conditions:
472 .Bl -bullet -offset 6u
473 .It
474 It includes characters from more than one line.
475 .It
476 It is specified using a line-oriented motion.
477 .It
478 It is specified using one of the following motion commands:
479 .Aq Cm control-A ,
480 .Cm ` Ns Aq Cm character ,
481 .Cm n ,
482 .Cm N ,
483 .Cm % ,
484 .Cm / ,
485 .Cm { ,
486 .Cm } ,
487 .Cm \&( ,
488 .Cm \&) ,
489 and
490 .Cm \&? .
491 .El
492 .Pp
493 Before this copy is done, the previous contents of buffer
494 .Sq 1
495 are moved into buffer
496 .Sq 2 ,
497 .Sq 2
498 into buffer
499 .Sq 3 ,
500 and so on.
501 The contents of buffer
502 .Sq 9
503 are discarded.
504 Note that this rotation occurs
505 .Em regardless
506 of the user specifying another buffer.
507 In
508 .Nm vi ,
509 text may be explicitly stored into the numeric buffers.
510 In this case, the buffer rotation occurs before the replacement of the buffer's
511 contents.
512 The numeric buffers are only available in
513 .Nm vi
514 mode.
515 .Sh VI COMMANDS
516 The following section describes the commands available in the command
517 mode of the
518 .Nm vi
519 editor.
520 The following words have a special meaning in the commands description:
521 .Pp
522 .Bl -tag -width bigword -compact -offset 3u
523 .It Ar bigword
524 A set of non-whitespace characters.
525 .It Ar buffer
526 Temporary area where commands may place text.
527 If not specified, the default buffer is used.
528 See also
529 .Sx BUFFERS ,
530 above.
531 .It Ar count
532 A positive number used to specify the desired number of iterations
533 of a command.
534 It defaults to 1 if not specified.
535 .It Ar motion
536 A cursor movement command which indicates the other end of the affected region
537 of text, the first being the current cursor position.
538 Repeating the command character makes it affect the whole current line.
539 .It Ar word
540 A sequence of letters, digits or underscores.
541 .El
542 .Pp
543 .Ar buffer
544 and
545 .Ar count ,
546 if both present, may be specified in any order.
547 .Ar motion
548 and
549 .Ar count ,
550 if both present, are effectively multiplied together
551 and considered part of the motion.
552 .Pp
553 .Bl -tag -width Ds -compact
554 .It Xo
555 .Aq Cm control-A
556 .Xc
557 Search forward
558 for the word starting at the cursor position.
559 .Pp
560 .It Xo
561 .Op Ar count
562 .Aq Cm control-B
563 .Xc
564 Page backwards
565 .Ar count
566 screens.
567 Two lines of overlap are maintained, if possible.
568 .Pp
569 .It Xo
570 .Op Ar count
571 .Aq Cm control-D
572 .Xc
573 Scroll forward
574 .Ar count
575 lines.
576 If
577 .Ar count
578 is not given, scroll forward the number of lines specified by the last
579 .Aq Cm control-D
580 or
581 .Aq Cm control-U
582 command.
583 If this is the first
584 .Aq Cm control-D
585 command, scroll half the number of lines in the current screen.
586 .Pp
587 .It Xo
588 .Op Ar count
589 .Aq Cm control-E
590 .Xc
591 Scroll forward
592 .Ar count
593 lines, leaving the current line and column as is, if possible.
594 .Pp
595 .It Xo
596 .Op Ar count
597 .Aq Cm control-F
598 .Xc
599 Page forward
600 .Ar count
601 screens.
602 Two lines of overlap are maintained, if possible.
603 .Pp
604 .It Aq Cm control-G
605 Display the following file information:
606 the file name
607 .Pq as given to Nm vi ;
608 whether the file has been modified since it was last written;
609 if the file is read-only;
610 the current line number;
611 the total number of lines in the file;
612 and the current line number as a percentage of the total lines in the file.
613 .Pp
614 .It Xo
615 .Op Ar count
616 .Aq Cm control-H
617 .Xc
618 .It Xo
619 .Op Ar count
620 .Cm h
621 .Xc
622 Move the cursor back
623 .Ar count
624 characters in the current line.
625 .Pp
626 .It Xo
627 .Op Ar count
628 .Aq Cm control-J
629 .Xc
630 .It Xo
631 .Op Ar count
632 .Aq Cm control-N
633 .Xc
634 .It Xo
635 .Op Ar count
636 .Cm j
637 .Xc
638 Move the cursor down
639 .Ar count
640 lines without changing the current column.
641 .Pp
642 .It Aq Cm control-L
643 .It Aq Cm control-R
644 Repaint the screen.
645 .Pp
646 .It Xo
647 .Op Ar count
648 .Aq Cm control-M
649 .Xc
650 .It Xo
651 .Op Ar count
652 .Cm +
653 .Xc
654 Move the cursor down
655 .Ar count
656 lines to the first non-blank character of that line.
657 .Pp
658 .It Xo
659 .Op Ar count
660 .Aq Cm control-P
661 .Xc
662 .It Xo
663 .Op Ar count
664 .Cm k
665 .Xc
666 Move the cursor up
667 .Ar count
668 lines, without changing the current column.
669 .Pp
670 .It Aq Cm control-T
671 Return to the most recent tag context.
672 .Pp
673 .It Xo
674 .Op Ar count
675 .Aq Cm control-U
676 .Xc
677 Scroll backwards
678 .Ar count
679 lines.
680 If
681 .Ar count
682 is not given, scroll backwards the number of lines specified by the last
683 .Aq Cm control-D
684 or
685 .Aq Cm control-U
686 command.
687 If this is the first
688 .Aq Cm control-U
689 command, scroll half the number of lines in the current screen.
690 .Pp
691 .It Aq Cm control-W
692 Switch to the next lower screen in the window,
693 or to the first screen if there are no lower screens in the window.
694 .Pp
695 .It Xo
696 .Op Ar count
697 .Aq Cm control-Y
698 .Xc
699 Scroll backwards
700 .Ar count
701 lines, leaving the current line and column as is, if possible.
702 .Pp
703 .It Aq Cm control-Z
704 Suspend the current editor session.
705 .Pp
706 .It Aq Cm escape
707 Execute the
708 .Nm ex
709 command being entered, or cancel it if it is only partial.
710 .Pp
711 .It Aq Cm control-]
712 Push a tag reference onto the tag stack.
713 .Pp
714 .It Aq Cm control-^
715 Switch to the most recently edited file.
716 .Pp
717 .It Xo
718 .Op Ar count
719 .Aq Cm space
720 .Xc
721 .It Xo
722 .Op Ar count
723 .Cm l
724 .Xc
725 Move the cursor forward
726 .Ar count
727 characters without changing the current line.
728 .Pp
729 .It Xo
730 .Op Ar count
731 .Cm !\&
732 .Ar motion shell-argument(s)
733 .Aq Li carriage-return
734 .Xc
735 Replace the lines spanned by
736 .Ar count
737 and
738 .Ar motion
739 with the output
740 .Pq standard output and standard error
741 of the program named by the
742 .Cm shell
743 option, called with a
744 .Fl c
745 flag followed by the
746 .Ar shell-argument(s)
747 .Pq bundled into a single argument .
748 Within
749 .Ar shell-argument(s) ,
750 the
751 .Sq % ,
752 .Sq #
753 and
754 .Sq !\&
755 characters are expanded to the current file name,
756 the previous current file name,
757 and the command text of the previous
758 .Cm !\&
759 or
760 .Cm :!
761 commands, respectively.
762 The special meaning of
763 .Sq % ,
764 .Sq #
765 and
766 .Sq !\&
767 can be overridden by escaping them with a backslash.
768 .Pp
769 .It Xo
770 .Op Ar count
771 .Cm #
772 .Sm off
773 .Cm # | + | -
774 .Sm on
775 .Xc
776 Increment
777 .Pq trailing So # Sc or So + Sc
778 or decrement
779 .Pq trailing Sq -
780 the number under the cursor by
781 .Ar count ,
782 starting at the cursor position or at the first non-blank
783 character following it.
784 Numbers with a leading
785 .Sq 0x
786 or
787 .Sq 0X
788 are interpreted as hexadecimal numbers.
789 Numbers with a leading
790 .Sq 0
791 are interpreted as octal numbers unless they contain a non-octal digit.
792 Other numbers may be prefixed with a
793 .Sq +
794 or
795 .Sq -
796 sign.
797 .Pp
798 .It Xo
799 .Op Ar count
800 .Cm $
801 .Xc
802 Move the cursor to the end of a line.
803 If
804 .Ar count
805 is specified, additionally move the cursor down
806 .Ar count
807 \- 1 lines.
808 .Pp
809 .It Cm %
810 Move to the
811 .Cm matchchars
812 character matching
813 the one found at the cursor position or the closest to the right of it.
814 .Pp
815 .It Cm &
816 Repeat the previous substitution command on the current line.
817 .Pp
818 .It Xo
819 .Cm ' Ns Aq Ar character
820 .Xc
821 .It Xo
822 .Cm ` Ns Aq Ar character
823 .Xc
824 Return to the cursor position marked by the character
825 .Ar character ,
826 or, if
827 .Ar character
828 is
829 .Sq '
830 or
831 .Sq ` ,
832 to the position of the cursor before the last of the following commands:
833 .Aq Cm control-A ,
834 .Aq Cm control-T ,
835 .Aq Cm control-] ,
836 .Cm % ,
837 .Cm ' ,
838 .Cm ` ,
839 .Cm (\& ,
840 .Cm )\& ,
841 .Cm / ,
842 .Cm ?\& ,
843 .Cm G ,
844 .Cm H ,
845 .Cm L ,
846 .Cm [[ ,
847 .Cm ]] ,
848 .Cm { ,
849 .Cm } .
850 The first form returns to the first non-blank character of the line marked by
851 .Ar character .
852 The second form returns to the line and column marked by
853 .Ar character .
854 .Pp
855 .It Xo
856 .Op Ar count
857 .Cm \&(
858 .Xc
859 .It Xo
860 .Op Ar count
861 .Cm \&)
862 .Xc
863 Move
864 .Ar count
865 sentences backward or forward, respectively.
866 A sentence is an area of text that begins with the first nonblank character
867 following the previous sentence, paragraph, or section
868 boundary and continues until the next period, exclamation point,
869 or question mark character, followed by any number of closing parentheses,
870 brackets, double or single quote characters, followed by
871 either an end-of-line or two whitespace characters.
872 Groups of empty lines
873 .Pq or lines containing only whitespace characters
874 are treated as a single sentence.
875 .Pp
876 .It Xo
877 .Op Ar count
878 .Cm ,\&
879 .Xc
880 Reverse find character
881 .Pq i.e., the last Cm F , f , T No or Cm t No command
882 .Ar count
883 times.
884 .Pp
885 .It Xo
886 .Op Ar count
887 .Cm -
888 .Xc
889 Move to the first non-blank character of the previous line,
890 .Ar count
891 times.
892 .Pp
893 .It Xo
894 .Op Ar count
895 .Cm .\&
896 .Xc
897 Repeat the last
898 .Nm vi
899 command that modified text.
900 .Ar count
901 replaces both the
902 .Ar count
903 argument of the repeated command and that of the associated
904 .Ar motion .
905 If the
906 .Cm .\&
907 command repeats the
908 .Cm u
909 command, the change log is rolled forward or backward, depending on the action
910 of the
911 .Cm u
912 command.
913 .Pp
914 .It Xo
915 .Pf / Ns Ar RE
916 .Aq Li carriage-return
917 .Xc
918 .It Xo
919 .Pf / Ns Ar RE Ns /
920 .Op Ar offset
921 .Op Cm z
922 .Aq Li carriage-return
923 .Xc
924 .It Xo
925 .Pf ?\& Ns Ar RE
926 .Aq Li carriage-return
927 .Xc
928 .It Xo
929 .Pf ?\& Ns Ar RE Ns ?\&
930 .Op Ar offset
931 .Op Cm z
932 .Aq Li carriage-return
933 .Xc
934 .It Cm N
935 .It Cm n
936 Search forward
937 .Pq Sq /
938 or backward
939 .Pq Sq ?\&
940 for a regular expression.
941 .Cm n
942 and
943 .Cm N
944 repeat the last search in the same or opposite directions, respectively.
945 If
946 .Ar RE
947 is empty, the last search regular expression is used.
948 If
949 .Ar offset
950 is specified, the cursor is placed
951 .Ar offset
952 lines before or after the matched regular expression.
953 If either
954 .Cm n
955 or
956 .Cm N
957 commands are used as motion components for the
958 .Cm !\&
959 command, there will be no prompt for the text of the command and the previous
960 .Cm !\&
961 will be executed.
962 Multiple search patterns may be grouped together by delimiting them with
963 semicolons and zero or more whitespace characters.
964 These patterns are evaluated from left to right with the final cursor position
965 determined by the last search pattern.
966 A
967 .Cm z
968 command may be appended to the closed search expressions to reposition the
969 result line.
970 .Pp
971 .It Cm 0
972 Move to the first character in the current line.
973 .Pp
974 .It Cm :\&
975 Execute an
976 .Nm ex
977 command.
978 .Pp
979 .It Xo
980 .Op Ar count
981 .Cm ;\&
982 .Xc
983 Repeat the last character find
984 .Pq i.e., the last .Cm F , f , T No or Cm t No command
985 .Ar count
986 times.
987 .Pp
988 .It Xo
989 .Op Ar count
990 .Cm <
991 .Ar motion
992 .Xc
993 .It Xo
994 .Op Ar count
995 .Cm >
996 .Ar motion
997 .Xc
998 Shift
999 .Ar count
1000 lines left or right, respectively, by an amount of
1001 .Cm shiftwidth .
1002 .Pp
1003 .It Cm @ Ar buffer
1004 Execute a named
1005 .Ar buffer
1006 as
1007 .Nm vi
1008 commands.
1009 The buffer may include
1010 .Nm ex
1011 commands too, but they must be expressed as a
1012 .Cm \&:
1013 command.
1014 If
1015 .Ar buffer
1016 is
1017 .Sq @
1018 or
1019 .Sq * ,
1020 then the last buffer executed shall be used.
1021 .Pp
1022 .It Xo
1023 .Op Ar count
1024 .Cm A
1025 .Xc
1026 Enter input mode, appending the text after the end of the line.
1027 If a
1028 .Ar count
1029 argument is given, the characters input are repeated
1030 .Ar count
1031 \- 1 times after input mode is exited.
1032 .Pp
1033 .It Xo
1034 .Op Ar count
1035 .Cm B
1036 .Xc
1037 Move backwards
1038 .Ar count
1039 bigwords.
1040 .Pp
1041 .It Xo
1042 .Op Ar buffer
1043 .Cm C
1044 .Xc
1045 Change text from the current position to the end-of-line.
1046 If
1047 .Ar buffer
1048 is specified,
1049 .Dq yank
1050 the deleted text into
1051 .Ar buffer .
1052 .Pp
1053 .It Xo
1054 .Op Ar buffer
1055 .Cm D
1056 .Xc
1057 Delete text from the current position to the end-of-line.
1058 If
1059 .Ar buffer
1060 is specified,
1061 .Dq yank
1062 the deleted text into
1063 .Ar buffer .
1064 .Pp
1065 .It Xo
1066 .Op Ar count
1067 .Cm E
1068 .Xc
1069 Move forward
1070 .Ar count
1071 end-of-bigwords.
1072 .Pp
1073 .It Xo
1074 .Op Ar count
1075 .Cm F Aq Ar character
1076 .Xc
1077 Search
1078 .Ar count
1079 times backward through the current line for
1080 .Aq Ar character .
1081 .Pp
1082 .It Xo
1083 .Op Ar count
1084 .Cm G
1085 .Xc
1086 Move to line
1087 .Ar count ,
1088 or the last line of the file if
1089 .Ar count
1090 is not specified.
1091 .Pp
1092 .It Xo
1093 .Op Ar count
1094 .Cm H
1095 .Xc
1096 Move to the screen line
1097 .Ar count
1098 \- 1 lines below the top of the screen.
1099 .Pp
1100 .It Xo
1101 .Op Ar count
1102 .Cm I
1103 .Xc
1104 Enter input mode, inserting the text at the beginning of the line.
1105 If a
1106 .Ar count
1107 argument is given,
1108 the characters input are repeated
1109 .Ar count
1110 \- 1 more times.
1111 .Pp
1112 .It Xo
1113 .Op Ar count
1114 .Cm J
1115 .Xc
1116 Join
1117 .Ar count
1118 lines with the current line.
1119 The spacing between two joined lines is set to two whitespace characters if the
1120 former ends with a question mark, a period or an exclamation point.
1121 It is set to one whitespace character otherwise.
1122 .Pp
1123 .It Xo
1124 .Op Ar count
1125 .Cm L
1126 .Xc
1127 Move to the screen line
1128 .Ar count
1129 \- 1 lines above the bottom of the screen.
1130 .Pp
1131 .It Cm M
1132 Move to the screen line in the middle of the screen.
1133 .Pp
1134 .It Xo
1135 .Op Ar count
1136 .Cm O
1137 .Xc
1138 Enter input mode, appending text in a new line above the current line.
1139 If a
1140 .Ar count
1141 argument is given,
1142 the characters input are repeated
1143 .Ar count
1144 \- 1 more times.
1145 .Pp
1146 .It Xo
1147 .Op Ar buffer
1148 .Cm P
1149 .Xc
1150 Insert text from
1151 .Ar buffer
1152 before the current column if
1153 .Ar buffer
1154 is character-oriented or before the current line if it is line-oriented.
1155 .Pp
1156 .It Cm Q
1157 Exit
1158 .Nm vi
1159 .Pq or visual
1160 mode and switch to
1161 .Nm ex
1162 mode.
1163 .Pp
1164 .It Xo
1165 .Op Ar count
1166 .Cm R
1167 .Xc
1168 Enter input mode, replacing the characters in the current line.
1169 If a
1170 .Ar count
1171 argument is given,
1172 the characters input are repeated
1173 .Ar count
1174 \- 1 more times upon exit from insert mode.
1175 .Pp
1176 .It Xo
1177 .Op Ar buffer
1178 .Op Ar count
1179 .Cm S
1180 .Xc
1181 Substitute
1182 .Ar count
1183 lines.
1184 If
1185 .Ar buffer
1186 is specified,
1187 .Dq yank
1188 the deleted text into
1189 .Ar buffer .
1190 .Pp
1191 .It Xo
1192 .Op Ar count
1193 .Cm T
1194 .Aq Ar character
1195 .Xc
1196 Search backwards,
1197 .Ar count
1198 times, through the current line for the character after the specified
1199 .Aq Ar character .
1200 .Pp
1201 .It Cm U
1202 Restore the current line to its state before the cursor last moved to it.
1203 .Pp
1204 .It Xo
1205 .Op Ar count
1206 .Cm W
1207 .Xc
1208 Move forward
1209 .Ar count
1210 bigwords.
1211 .Pp
1212 .It Xo
1213 .Op Ar buffer
1214 .Op Ar count
1215 .Cm X
1216 .Xc
1217 Delete
1218 .Ar count
1219 characters before the cursor, on the current line.
1220 If
1221 .Ar buffer
1222 is specified,
1223 .Dq yank
1224 the deleted text into
1225 .Ar buffer .
1226 .Pp
1227 .It Xo
1228 .Op Ar buffer
1229 .Op Ar count
1230 .Cm Y
1231 .Xc
1232 Copy
1233 .Pq or Dq yank
1234 .Ar count
1235 lines into
1236 .Ar buffer .
1237 .Pp
1238 .It Cm ZZ
1239 Write the file and exit
1240 .Nm vi
1241 if there are no more files to edit.
1242 Entering two
1243 .Dq quit
1244 commands in a row ignores any remaining file to edit.
1245 .Pp
1246 .It Xo
1247 .Op Ar count
1248 .Cm [[
1249 .Xc
1250 Back up
1251 .Ar count
1252 section boundaries.
1253 .Pp
1254 .It Xo
1255 .Op Ar count
1256 .Cm ]]
1257 .Xc
1258 Move forward
1259 .Ar count
1260 section boundaries.
1261 .Pp
1262 .It Cm ^
1263 Move to the first non-blank character on the current line.
1264 .Pp
1265 .It Xo
1266 .Op Ar count
1267 .Cm _
1268 .Xc
1269 Move down
1270 .Ar count
1271 \- 1 lines, to the first non-blank character.
1272 .Pp
1273 .It Xo
1274 .Op Ar count
1275 .Cm a
1276 .Xc
1277 Enter input mode, appending the text after the cursor.
1278 If a
1279 .Ar count
1280 argument is given,
1281 the characters input are repeated
1282 .Ar count
1283 number of times.
1284 .Pp
1285 .It Xo
1286 .Op Ar count
1287 .Cm b
1288 .Xc
1289 Move backwards
1290 .Ar count
1291 words.
1292 .Pp
1293 .It Xo
1294 .Op Ar buffer
1295 .Op Ar count
1296 .Cm c
1297 .Ar motion
1298 .Xc
1299 Change the region of text described by
1300 .Ar count
1301 and
1302 .Ar motion .
1303 If
1304 .Ar buffer
1305 is specified,
1306 .Dq yank
1307 the changed text into
1308 .Ar buffer .
1309 .Pp
1310 .It Xo
1311 .Op Ar buffer
1312 .Op Ar count
1313 .Cm d
1314 .Ar motion
1315 .Xc
1316 Delete the region of text described by
1317 .Ar count
1318 and
1319 .Ar motion .
1320 If
1321 .Ar buffer
1322 is specified,
1323 .Dq yank
1324 the deleted text into
1325 .Ar buffer .
1326 .Pp
1327 .It Xo
1328 .Op Ar count
1329 .Cm e
1330 .Xc
1331 Move forward
1332 .Ar count
1333 end-of-words.
1334 .Pp
1335 .It Xo
1336 .Op Ar count
1337 .Cm f Aq Ar character
1338 .Xc
1339 Search forward,
1340 .Ar count
1341 times, through the rest of the current line for
1342 .Aq Ar character .
1343 .Pp
1344 .It Xo
1345 .Op Ar count
1346 .Cm i
1347 .Xc
1348 Enter input mode, inserting the text before the cursor.
1349 If a
1350 .Ar count
1351 argument is given,
1352 the characters input are repeated
1353 .Ar count
1354 number of times.
1355 .Pp
1356 .It Xo
1357 .Cm m
1358 .Aq Ar character
1359 .Xc
1360 Save the current context
1361 .Pq line and column
1362 as
1363 .Aq Ar character .
1364 .Pp
1365 .It Xo
1366 .Op Ar count
1367 .Cm o
1368 .Xc
1369 Enter input mode, appending text in a new line under the current line.
1370 If a
1371 .Ar count
1372 argument is given,
1373 the characters input are repeated
1374 .Ar count
1375 \- 1 more times.
1376 .Pp
1377 .It Xo
1378 .Op Ar buffer
1379 .Cm p
1380 .Xc
1381 Append text from
1382 .Ar buffer .
1383 Text is appended after the current column if
1384 .Ar buffer
1385 is character oriented, or after the current line otherwise.
1386 .Pp
1387 .It Xo
1388 .Op Ar count
1389 .Cm r
1390 .Aq Ar character
1391 .Xc
1392 Replace
1393 .Ar count
1394 characters with
1395 .Ar character .
1396 .Pp
1397 .It Xo
1398 .Op Ar buffer
1399 .Op Ar count
1400 .Cm s
1401 .Xc
1402 Substitute
1403 .Ar count
1404 characters in the current line starting with the current character.
1405 If
1406 .Ar buffer
1407 is specified,
1408 .Dq yank
1409 the substituted text into
1410 .Ar buffer .
1411 .Pp
1412 .It Xo
1413 .Op Ar count
1414 .Cm t
1415 .Aq Ar character
1416 .Xc
1417 Search forward,
1418 .Ar count
1419 times, through the current line for the character immediately before
1420 .Aq Ar character .
1421 .Pp
1422 .It Cm u
1423 Undo the last change made to the file.
1424 If repeated, the
1425 .Cm u
1426 command alternates between these two states.
1427 The
1428 .Cm .\&
1429 command, when used immediately after
1430 .Cm u ,
1431 causes the change log to be rolled forward or backward, depending on the action
1432 of the
1433 .Cm u
1434 command.
1435 .Pp
1436 .It Xo
1437 .Op Ar count
1438 .Cm w
1439 .Xc
1440 Move forward
1441 .Ar count
1442 words.
1443 .Pp
1444 .It Xo
1445 .Op Ar buffer
1446 .Op Ar count
1447 .Cm x
1448 .Xc
1449 Delete
1450 .Ar count
1451 characters at the current cursor position, but no more than there are till the
1452 end of the line.
1453 .Pp
1454 .It Xo
1455 .Op Ar buffer
1456 .Op Ar count
1457 .Cm y
1458 .Ar motion
1459 .Xc
1460 Copy
1461 .Pq or Dq yank
1462 a text region specified by
1463 .Ar count
1464 and
1465 .Ar motion
1466 into a buffer.
1467 .Pp
1468 .It Xo
1469 .Op Ar count1
1470 .Cm z
1471 .Op Ar count2
1472 .Cm type
1473 .Xc
1474 Redraw, optionally repositioning and resizing the screen.
1475 If
1476 .Ar count2
1477 is specified, limit the screen size to
1478 .Ar count2
1479 lines.
1480 The following
1481 .Cm type
1482 characters may be used:
1483 .Bl -tag -width Ds
1484 .It Cm +
1485 If
1486 .Ar count1
1487 is specified, place the line
1488 .Ar count1
1489 at the top of the screen.
1490 Otherwise, display the screen after the current screen.
1491 .It Aq Cm carriage-return
1492 Place the line
1493 .Ar count1
1494 at the top of the screen.
1495 .It Cm .\&
1496 Place the line
1497 .Ar count1
1498 in the center of the screen.
1499 .It Cm -
1500 Place the line
1501 .Ar count1
1502 at the bottom of the screen.
1503 .It Cm ^
1504 If
1505 .Ar count1
1506 is given,
1507 display the screen before the screen before
1508 .Ar count1
1509 .Pq i.e., 2 screens before .
1510 Otherwise, display the screen before the current screen.
1511 .El
1512 .Pp
1513 .It Xo
1514 .Op Ar count
1515 .Cm {\&
1516 .Xc
1517 Move backward
1518 .Ar count
1519 paragraphs.
1520 .Pp
1521 .It Xo
1522 .Op Ar column
1523 .Cm |\&
1524 .Xc
1525 Move to a specific
1526 .Ar column
1527 position on the current line.
1528 If
1529 .Ar column
1530 is omitted,
1531 move to the start of the current line.
1532 .Pp
1533 .It Xo
1534 .Op Ar count
1535 .Cm }\&
1536 .Xc
1537 Move forward
1538 .Ar count
1539 paragraphs.
1540 .Pp
1541 .It Xo
1542 .Op Ar count
1543 .Cm ~
1544 .Ar motion
1545 .Xc
1546 If the
1547 .Cm tildeop
1548 option is not set, reverse the case of the next
1549 .Ar count
1550 character(s) and no
1551 .Ar motion
1552 can be specified.
1553 Otherwise
1554 .Ar motion
1555 is mandatory and
1556 .Cm ~
1557 reverses the case of the characters in a text region specified by the
1558 .Ar count
1559 and
1560 .Ar motion .
1561 .Pp
1562 .It Aq Cm interrupt
1563 Interrupt the current operation.
1564 The
1565 .Aq interrupt
1566 character is usually
1567 .Aq control-C .
1568 .El
1569 .Sh VI TEXT INPUT COMMANDS
1570 The following section describes the commands available in the text input mode
1571 of the
1572 .Nm vi
1573 editor.
1574 .Pp
1575 .Bl -tag -width Ds -compact
1576 .It Aq Cm nul
1577 Replay the previous input.
1578 .Pp
1579 .It Aq Cm control-D
1580 Erase to the previous
1581 .Ar shiftwidth
1582 column boundary.
1583 .Pp
1584 .It Cm ^ Ns Aq Cm control-D
1585 Erase all of the autoindent characters, and reset the autoindent level.
1586 .Pp
1587 .It Cm 0 Ns Aq Cm control-D
1588 Erase all of the autoindent characters.
1589 .Pp
1590 .It Aq Cm control-T
1591 Insert sufficient
1592 .Aq tab
1593 and
1594 .Aq space
1595 characters to move forward to the next
1596 .Ar shiftwidth
1597 column boundary.
1598 .Pp
1599 .It Aq Cm erase
1600 .It Aq Cm control-H
1601 Erase the last character.
1602 .Pp
1603 .It Aq Cm literal next
1604 Escape the next character from any special meaning.
1605 The
1606 .Aq literal\ \&next
1607 character is usually
1608 .Aq control-V .
1609 .Pp
1610 .It Aq Cm escape
1611 Resolve all text input into the file, and return to command mode.
1612 .Pp
1613 .It Aq Cm line erase
1614 Erase the current line.
1615 .Pp
1616 .It Aq Cm control-W
1617 .It Aq Cm word erase
1618 Erase the last word.
1619 The definition of word is dependent on the
1620 .Cm altwerase
1621 and
1622 .Cm ttywerase
1623 options.
1624 .Pp
1625 .Sm off
1626 .It Xo
1627 .Aq Cm control-X
1628 .Bq Cm 0-9A-Fa-f
1629 .Cm +
1630 .Xc
1631 .Sm on
1632 Insert a character with the specified hexadecimal value into the text.
1633 .Pp
1634 .It Aq Cm interrupt
1635 Interrupt text input mode, returning to command mode.
1636 The
1637 .Aq interrupt
1638 character is usually
1639 .Aq control-C .
1640 .El
1641 .Sh EX COMMANDS
1642 The following section describes the commands available in the
1643 .Nm ex
1644 editor.
1645 In each entry below, the tag line is a usage synopsis for the command.
1646 .Pp
1647 .Bl -tag -width Ds -compact
1648 .It Aq Cm end-of-file
1649 Scroll the screen.
1650 .Pp
1651 .It Cm !\& Ar argument(s)
1652 .It Xo
1653 .Op Ar range
1654 .Cm !\&
1655 .Ar argument(s)
1656 .Xc
1657 Execute a shell command, or filter lines through a shell command.
1658 .Pp
1659 .It Cm \&"
1660 A comment.
1661 .Pp
1662 .It Xo
1663 .Op Ar range
1664 .Cm nu Ns Op Cm mber
1665 .Op Ar count
1666 .Op Ar flags
1667 .Xc
1668 .It Xo
1669 .Op Ar range
1670 .Cm #
1671 .Op Ar count
1672 .Op Ar flags
1673 .Xc
1674 Display the selected lines, each preceded with its line number.
1675 .Pp
1676 .It Cm @ Ar buffer
1677 .It Cm * Ar buffer
1678 Execute a buffer.
1679 .Pp
1680 .It Xo
1681 .Op Ar range
1682 .Cm < Ns Op Cm < ...
1683 .Op Ar count
1684 .Op Ar flags
1685 .Xc
1686 Shift lines left.
1687 .Pp
1688 .It Xo
1689 .Op Ar line
1690 .Cm =
1691 .Op Ar flags
1692 .Xc
1693 Display the line number of
1694 .Ar line .
1695 If
1696 .Ar line
1697 is not specified, display the line number of the last line in the file.
1698 .Pp
1699 .It Xo
1700 .Op Ar range
1701 .Cm > Ns Op Cm > ...
1702 .Op Ar count
1703 .Op Ar flags
1704 .Xc
1705 Shift lines right.
1706 .Pp
1707 .It Xo
1708 .Cm ab Ns Op Cm breviate
1709 .Ar lhs rhs
1710 .Xc
1711 .Nm vi
1712 only.
1713 Add
1714 .Ar lhs
1715 as an abbreviation for
1716 .Ar rhs
1717 to the abbreviation list.
1718 .Pp
1719 .It Xo
1720 .Op Ar line
1721 .Cm a Ns Op Cm ppend Ns
1722 .Op Cm !\&
1723 .Xc
1724 The input text is appended after the specified line.
1725 .Pp
1726 .It Cm ar Ns Op Cm gs
1727 Display the argument list.
1728 .Pp
1729 .It Cm bg
1730 .Nm vi
1731 only.
1732 Background the current screen.
1733 .Pp
1734 .It Xo
1735 .Op Ar range
1736 .Cm c Ns Op Cm hange Ns
1737 .Op Cm !\&
1738 .Op Ar count
1739 .Xc
1740 The input text replaces the specified range.
1741 .Pp
1742 .It Xo
1743 .Cm chd Ns Op Cm ir Ns
1744 .Op Cm !\&
1745 .Op Ar directory
1746 .Xc
1747 .It Xo
1748 .Cm cd Ns Op Cm !\&
1749 .Op Ar directory
1750 .Xc
1751 Change the current working directory.
1752 .Pp
1753 .It Xo
1754 .Op Ar range
1755 .Cm co Ns Op Cm py
1756 .Ar line
1757 .Op Ar flags
1758 .Xc
1759 .It Xo
1760 .Op Ar range
1761 .Cm t
1762 .Ar line
1763 .Op Ar flags
1764 .Xc
1765 Copy the specified lines after the destination
1766 .Ar line .
1767 .Pp
1768 .It Xo
1769 .Cm cs Ns Op Cm cope
1770 .Cm add | find | help | kill | reset
1771 .Xc
1772 Execute a Cscope command.
1773 .Pp
1774 .It Xo
1775 .Op Ar range
1776 .Cm d Ns Op Cm elete
1777 .Op Ar buffer
1778 .Op Ar count
1779 .Op Ar flags
1780 .Xc
1781 Delete the lines from the file.
1782 .Pp
1783 .It Xo
1784 .Cm di Ns Op Cm splay
1785 .Cm b Ns Oo Cm uffers Oc |
1786 .Cm c Ns Oo Cm onnections Oc |
1787 .Cm s Ns Oo Cm creens Oc |
1788 .Cm t Ns Op Cm ags
1789 .Xc
1790 Display buffers, Cscope connections, screens or tags.
1791 .Pp
1792 .It Xo
1793 .Op Cm Ee Ns
1794 .Op Cm dit Ns
1795 .Op Cm !\&
1796 .Op Ar +cmd
1797 .Op Ar file
1798 .Xc
1799 .It Xo
1800 .Op Cm Ee Ns
1801 .Cm x Ns Op Cm !\&
1802 .Op Ar +cmd
1803 .Op Ar file
1804 .Xc
1805 Edit a different file.
1806 .Pp
1807 .It Xo
1808 .Cm exu Ns Op Cm sage
1809 .Op Ar command
1810 .Xc
1811 Display usage for an
1812 .Nm ex
1813 command.
1814 .Pp
1815 .It Xo
1816 .Cm f Ns Op Cm ile
1817 .Op Ar file
1818 .Xc
1819 Display and optionally change the file name.
1820 .Pp
1821 .It Xo
1822 .Op Cm Ff Ns
1823 .Cm g
1824 .Op Ar name
1825 .Xc
1826 .Nm vi
1827 mode only.
1828 Foreground the specified screen.
1829 .Pp
1830 .It Xo
1831 .Op Ar range
1832 .Cm g Ns Op Cm lobal
1833 .No / Ns Ar pattern Ns /
1834 .Op Ar commands
1835 .Xc
1836 .It Xo
1837 .Op Ar range
1838 .Cm v
1839 .No / Ns Ar pattern Ns /
1840 .Op Ar commands
1841 .Xc
1842 Apply commands to lines matching
1843 .Pq Sq global
1844 or not matching
1845 .Pq Sq v
1846 a pattern.
1847 .Pp
1848 .It Cm he Ns Op Cm lp
1849 Display a help message.
1850 .Pp
1851 .It Xo
1852 .Op Ar line
1853 .Cm i Ns Op Cm nsert Ns
1854 .Op Cm !\&
1855 .Xc
1856 The input text is inserted before the specified line.
1857 .Pp
1858 .It Xo
1859 .Op Ar range
1860 .Cm j Ns Op Cm oin Ns
1861 .Op Cm !\&
1862 .Op Ar count
1863 .Op Ar flags
1864 .Xc
1865 Join lines of text together.
1866 .Pp
1867 .It Xo
1868 .Op Ar range
1869 .Cm l Ns Op Cm ist
1870 .Op Ar count
1871 .Op Ar flags
1872 .Xc
1873 Display the lines unambiguously.
1874 .Pp
1875 .It Xo
1876 .Cm map Ns Op Cm !\&
1877 .Op Ar lhs rhs
1878 .Xc
1879 Define or display maps
1880 .Pq for Nm vi No only .
1881 .Pp
1882 .It Xo
1883 .Op Ar line
1884 .Cm ma Ns Op Cm rk
1885 .Aq Ar character
1886 .Xc
1887 .It Xo
1888 .Op Ar line
1889 .Cm k Aq Ar character
1890 .Xc
1891 Mark the line with the mark
1892 .Aq Ar character .
1893 .Pp
1894 .It Xo
1895 .Op Ar range
1896 .Cm m Ns Op Cm ove
1897 .Ar line
1898 .Xc
1899 Move the specified lines after the target line.
1900 .Pp
1901 .It Xo
1902 .Cm mk Ns Op Cm exrc Ns
1903 .Op Cm !\&
1904 .Ar file
1905 .Xc
1906 Write the abbreviations, editor options and maps to the specified
1907 .Ar file .
1908 .Pp
1909 .It Xo
1910 .Op Cm Nn Ns
1911 .Op Cm ext Ns
1912 .Op Cm !\&
1913 .Op Ar
1914 .Xc
1915 Edit the next file from the argument list.
1916 .\" .Pp
1917 .\" .It Xo
1918 .\" .Op Ar line
1919 .\" .Cm o Ns Op Cm pen
1920 .\" .No / Ns Ar pattern Ns /
1921 .\" .Op Ar flags
1922 .\" .Xc
1923 .\" Enter open mode.
1924 .Pp
1925 .It Cm pre Ns Op Cm serve
1926 Save the file in a form that can later be recovered using the
1927 .Nm ex
1928 .Fl r
1929 option.
1930 .Pp
1931 .It Xo
1932 .Op Cm \&Pp Ns
1933 .Cm rev Ns Op Cm ious Ns
1934 .Op Cm !\&
1935 .Xc
1936 Edit the previous file from the argument list.
1937 .Pp
1938 .It Xo
1939 .Op Ar range
1940 .Cm p Ns Op Cm rint
1941 .Op Ar count
1942 .Op Ar flags
1943 .Xc
1944 Display the specified lines.
1945 .Pp
1946 .It Xo
1947 .Op Ar line
1948 .Cm pu Ns Op Cm t
1949 .Op Ar buffer
1950 .Xc
1951 Append buffer contents to the current line.
1952 .Pp
1953 .It Xo
1954 .Cm q Ns Op Cm uit Ns
1955 .Op Cm !\&
1956 .Xc
1957 End the editing session.
1958 .Pp
1959 .It Xo
1960 .Op Ar line
1961 .Cm r Ns Op Cm ead Ns
1962 .Op Cm !\&
1963 .Op Ar file
1964 .Xc
1965 Read a file.
1966 .Pp
1967 .It Xo
1968 .Cm rec Ns Op Cm over
1969 .Ar file
1970 .Xc
1971 Recover
1972 .Ar file
1973 if it was previously saved.
1974 .Pp
1975 .It Xo
1976 .Cm res Ns Op Cm ize
1977 .Op Cm + Ns | Ns Cm - Ns
1978 .Ar size
1979 .Xc
1980 .Nm vi
1981 mode only.
1982 Grow or shrink the current screen.
1983 .Pp
1984 .It Xo
1985 .Cm rew Ns Op Cm ind Ns
1986 .Op Cm !\&
1987 .Xc
1988 Rewind the argument list.
1989 .Pp
1990 .It Xo
1991 .Cm se Ns Op Cm t
1992 .Sm off
1993 .Op option Oo = Oo value Oc Oc \ \&...
1994 .Sm on
1995 .Pf \ \& Op nooption ...
1996 .Op option? ...
1997 .Op Ar all
1998 .Xc
1999 Display or set editor options.
2000 .Pp
2001 .It Cm sh Ns Op Cm ell
2002 Run a shell program.
2003 .Pp
2004 .It Xo
2005 .Cm so Ns Op Cm urce
2006 .Ar file
2007 .Xc
2008 Read and execute
2009 .Nm ex
2010 commands from a file.
2011 .Pp
2012 .It Xo
2013 .Op Ar range
2014 .Cm s Ns Op Cm ubstitute
2015 .Sm off
2016 .Op / Ar pattern No / Ar replace No /
2017 .Sm on
2018 .Pf \ \& Op Ar options
2019 .Op Ar count
2020 .Op Ar flags
2021 .Xc
2022 .It Xo
2023 .Op Ar range
2024 .Cm &
2025 .Op Ar options
2026 .Op Ar count
2027 .Op Ar flags
2028 .Xc
2029 .It Xo
2030 .Op Ar range
2031 .Cm ~
2032 .Op Ar options
2033 .Op Ar count
2034 .Op Ar flags
2035 .Xc
2036 Make substitutions.
2037 The
2038 .Ar replace
2039 field may contain any of the following sequences:
2040 .Bl -tag -width Ds
2041 .It Sq \*(Am
2042 The text matched by
2043 .Ar pattern .
2044 .It Sq \(a~
2045 The replacement part of the previous
2046 .Cm substitute
2047 command.
2048 .It Sq %
2049 If this is the entire
2050 .Ar replace
2051 pattern, the replacement part of the previous
2052 .Cm substitute
2053 command.
2054 .It Sq \e\(sh
2055 Where
2056 .Sq \(sh
2057 is an integer from 1 to 9, the text matched by the #'th subexpression in
2058 .Ar pattern .
2059 .It Sq \eL
2060 Causes the characters up to the end of the line of the next occurrence of
2061 .Sq \eE
2062 or
2063 .Sq \ee
2064 to be converted to lowercase.
2065 .It Sq \el
2066 Causes the next character to be converted to lowercase.
2067 .It Sq \eU
2068 Causes the characters up to the end of the line of the next occurrence of
2069 .Sq \eE
2070 or
2071 .Sq \ee
2072 to be converted to uppercase.
2073 .It Sq \eu
2074 Causes the next character to be converted to uppercase.
2075 .El
2076 .Pp
2077 .It Xo
2078 .Cm su Ns Op Cm spend Ns
2079 .Op Cm !\&
2080 .Xc
2081 .It Xo
2082 .Cm st Ns Op Cm op Ns
2083 .Op Cm !\&
2084 .Xc
2085 .It Aq Cm suspend
2086 Suspend the edit session.
2087 The
2088 .Aq suspend
2089 character is usually
2090 .Aq control-Z .
2091 .Pp
2092 .It Xo
2093 .Op Cm Tt Ns
2094 .Cm a Ns Op Cm g Ns
2095 .Op Cm !\&
2096 .Ar tagstring
2097 .Xc
2098 Edit the file containing the specified tag.
2099 .Pp
2100 .It Xo
2101 .Cm tagn Ns Op Cm ext Ns
2102 .Op Cm !\&
2103 .Xc
2104 Edit the file containing the next context for the current tag.
2105 .Pp
2106 .It Xo
2107 .Cm tagp Ns Op Cm op Ns
2108 .Op Cm !\&
2109 .Op Ar file | number
2110 .Xc
2111 Pop to the specified tag in the tags stack.
2112 .Pp
2113 .It Xo
2114 .Cm tagpr Ns Op Cm ev Ns
2115 .Op Cm !\&
2116 .Xc
2117 Edit the file containing the previous context for the current tag.
2118 .Pp
2119 .It Xo
2120 .Cm tagt Ns Op Cm op Ns
2121 .Op Cm !\&
2122 .Xc
2123 Pop to the least recent tag on the tags stack, clearing the stack.
2124 .Pp
2125 .It Xo
2126 .Cm una Ns Op Cm bbreviate
2127 .Ar lhs
2128 .Xc
2129 .Nm vi
2130 only.
2131 Delete an abbreviation.
2132 .Pp
2133 .It Cm u Ns Op Cm ndo
2134 Undo the last change made to the file.
2135 .Pp
2136 .It Xo
2137 .Cm unm Ns Op Cm ap Ns
2138 .Op Cm !\&
2139 .Ar lhs
2140 .Xc
2141 Unmap a mapped string.
2142 .Pp
2143 .It Cm ve Ns Op Cm rsion
2144 Display the version of the
2145 .Nm ex Ns / Ns Nm vi
2146 editor.
2147 .Pp
2148 .It Xo
2149 .Op Ar line
2150 .Cm vi Ns Op Cm sual
2151 .Op Ar type
2152 .Op Ar count
2153 .Op Ar flags
2154 .Xc
2155 .Nm ex
2156 mode only.
2157 Enter
2158 .Nm vi .
2159 .Pp
2160 .It Xo
2161 .Op Cm Vi Ns
2162 .Cm i Ns Op Cm sual Ns
2163 .Op Cm !\&
2164 .Op Ar +cmd
2165 .Op Ar file
2166 .Xc
2167 .Nm vi
2168 mode only.
2169 Edit a new file.
2170 .Pp
2171 .It Xo
2172 .Cm viu Ns Op Cm sage
2173 .Op Ar command
2174 .Xc
2175 Display usage for a
2176 .Nm vi
2177 command.
2178 .Pp
2179 .It Xo
2180 .Op Ar range
2181 .Cm w Ns Op Cm rite Ns
2182 .Op Cm !\&
2183 .Op >>
2184 .Op Ar file
2185 .Xc
2186 .It Xo
2187 .Op Ar range
2188 .Cm w Ns Op Cm rite
2189 .Op Cm !\&
2190 .Op Ar file
2191 .Xc
2192 .It Xo
2193 .Op Ar range
2194 .Cm wn Ns Op Cm !\&
2195 .Op >>
2196 .Op Ar file
2197 .Xc
2198 .It Xo
2199 .Op Ar range
2200 .Cm wq Ns Op Cm !\&
2201 .Op >>
2202 .Op Ar file
2203 .Xc
2204 Write the file.
2205 .Pp
2206 .It Xo
2207 .Op Ar range
2208 .Cm x Ns Op Cm it Ns
2209 .Op Cm !\&
2210 .Op Ar file
2211 .Xc
2212 Exit the editor,
2213 writing the file if it has been modified.
2214 .Pp
2215 .It Xo
2216 .Op Ar range
2217 .Cm ya Ns Op Cm nk
2218 .Op Ar buffer
2219 .Op Ar count
2220 .Xc
2221 Copy the specified lines to a buffer.
2222 .Pp
2223 .It Xo
2224 .Op Ar line
2225 .Cm z
2226 .Op Ar type
2227 .Op Ar count
2228 .Op Ar flags
2229 .Xc
2230 Adjust the window.
2231 .El
2232 .Sh SET OPTIONS
2233 There are a large number of options that may be set
2234 .Pq or unset
2235 to change the editor's behavior.
2236 This section describes the options, their abbreviations and their
2237 default values.
2238 .Pp
2239 In each entry below, the first part of the tag line is the full name
2240 of the option, followed by any equivalent abbreviations.
2241 The part in square brackets is the default value of the option.
2242 Most of the options are boolean, i.e., they are either on or off,
2243 and do not have an associated value.
2244 .Pp
2245 Options apply to both
2246 .Nm ex
2247 and
2248 .Nm vi
2249 modes, unless otherwise specified.
2250 .Bl -tag -width Ds
2251 .It Cm altwerase Bq off
2252 .Nm vi
2253 only.
2254 Select an alternate word erase algorithm.
2255 .It Cm autoindent , ai Bq off
2256 Automatically indent new lines.
2257 .It Cm autoprint , ap Bq on
2258 .Nm ex
2259 only.
2260 Display the current line automatically.
2261 .It Cm autowrite , aw Bq off
2262 Write modified files automatically when changing files or suspending the editor
2263 session.
2264 .It Cm backup Bq \&"\&"
2265 Back up files before they are overwritten.
2266 .It Cm beautify , bf Bq off
2267 Discard control characters.
2268 .It Cm cdpath Bq "environment variable CDPATH, or current directory"
2269 The directory paths used as path prefixes for the
2270 .Cm cd
2271 command.
2272 .It Cm cedit Bq no default
2273 Set the character to edit the colon command-line history.
2274 .It Cm columns , co Bq 80
2275 Set the number of columns in the screen.
2276 .It Cm comment Bq off
2277 .Nm vi
2278 only.
2279 Skip leading comments in shell, C and C++ language files.
2280 .It Cm directory , dir Bq "environment variable TMPDIR, or /tmp"
2281 The directory where temporary files are created.
2282 .It Cm edcompatible , ed Bq off
2283 Remember the values of the
2284 .Sq c
2285 and
2286 .Sq g
2287 suffixes to the
2288 .Cm substitute
2289 commands, instead of initializing them as unset for each new command.
2290 .It Cm errorbells , eb Bq off
2291 .Nm ex
2292 only.
2293 Announce error messages with a bell.
2294 .It Cm escapetime Bq 1
2295 The tenths of a second
2296 .Nm ex Ns / Ns Nm vi
2297 waits for a subsequent key to complete an
2298 .Aq escape
2299 key mapping.
2300 .It Cm exrc , ex Bq off
2301 Read the startup files in the local directory.
2302 .It Cm extended Bq off
2303 Use extended regular expressions
2304 .Pq EREs
2305 rather than basic regular expressions
2306 .Pq BREs .
2307 See
2308 .Xr re_format 7
2309 for more information on regular expressions.
2310 .It Cm filec Bq Aq tab
2311 Set the character to perform file path completion on the colon command line.
2312 .It Cm fileencoding , fe Bq auto detect
2313 Set the encoding of the current file.
2314 .It Cm flash Bq on
2315 Flash the screen instead of beeping the keyboard on error.
2316 .It Cm hardtabs, ht Bq 0
2317 Set the spacing between hardware tab settings.
2318 This option currently has no effect.
2319 .It Cm iclower Bq off
2320 Makes all regular expressions case-insensitive,
2321 as long as an upper-case letter does not appear in the search string.
2322 .It Cm ignorecase , ic Bq off
2323 Ignore case differences in regular expressions.
2324 .It Cm inputencoding , ie Bq locale
2325 Set the encoding of your input characters.
2326 .It Cm keytime Bq 6
2327 The tenths of a second
2328 .Nm ex Ns / Ns Nm vi
2329 waits for a subsequent key to complete a key mapping.
2330 .It Cm leftright Bq off
2331 .Nm vi
2332 only.
2333 Do left-right scrolling.
2334 .It Cm lines , li Bq 24
2335 .Nm vi
2336 only.
2337 Set the number of lines in the screen.
2338 .It Cm lisp Bq off
2339 .Nm vi
2340 only.
2341 Modify various search commands and options to work with Lisp.
2342 This option is not yet implemented.
2343 .It Cm list Bq off
2344 Display lines in an unambiguous fashion.
2345 .It Cm lock Bq on
2346 Attempt to get an exclusive lock on any file being edited, read or written.
2347 .It Cm magic Bq on
2348 When turned off, all regular expression characters except for
2349 .Sq \(ha
2350 and
2351 .Sq \(Do
2352 are treated as ordinary characters.
2353 Preceding individual characters by
2354 .Sq \e
2355 re-enables them.
2356 .It Cm matchchars Bq []{}()
2357 Character pairs looked for by the
2358 .Cm %
2359 command.
2360 .It Cm matchtime Bq 7
2361 .Nm vi
2362 only.
2363 The tenths of a second
2364 .Nm ex Ns / Ns Nm vi
2365 pauses on the matching character when the
2366 .Cm showmatch
2367 option is set.
2368 .It Cm mesg Bq on
2369 Permit messages from other users.
2370 .It Cm msgcat Bq /usr/share/vi/catalog/
2371 Selects a message catalog to be used to display error and informational
2372 messages in a specified language.
2373 .It Cm modelines , modeline Bq off
2374 Read the first and last few lines of each file for
2375 .Nm ex
2376 commands.
2377 This option will never be implemented.
2378 .It Cm noprint Bq \&"\&"
2379 Characters that are never handled as printable characters.
2380 .It Cm number , nu Bq off
2381 Precede each line displayed with its current line number.
2382 .It Cm octal Bq off
2383 Display unknown characters as octal numbers, instead of the default
2384 hexadecimal.
2385 .It Cm open Bq on
2386 .Nm ex
2387 only.
2388 If this option is not set, the
2389 .Cm open
2390 and
2391 .Cm visual
2392 commands are disallowed.
2393 .It Cm optimize , opt Bq on
2394 .Nm vi
2395 only.
2396 Optimize text throughput to dumb terminals.
2397 This option is not yet implemented.
2398 .It Cm paragraphs , para Bq "IPLPPPQPP LIpplpipbp"
2399 .Nm vi
2400 only.
2401 Define additional paragraph boundaries for the
2402 .Cm {\&
2403 and
2404 .Cm }\&
2405 commands.
2406 .It Cm path Bq \&"\&"
2407 Define additional directories to search for files being edited.
2408 .It Cm print Bq \&"\&"
2409 Characters that are always handled as printable characters.
2410 .It Cm prompt Bq on
2411 .Nm ex
2412 only.
2413 Display a command prompt.
2414 .It Cm readonly , ro Bq off
2415 Mark the file and session as read-only.
2416 .It Cm recdir Bq /var/tmp/vi.recover
2417 The directory where recovery files are stored.
2418 .It Cm redraw , re Bq off
2419 .Nm vi
2420 only.
2421 Simulate an intelligent terminal on a dumb one.
2422 This option is not yet implemented.
2423 .It Cm remap Bq on
2424 Remap keys until resolved.
2425 .It Cm report Bq 5
2426 Set the number of lines about which the editor reports changes or yanks.
2427 .It Cm ruler Bq off
2428 .Nm vi
2429 only.
2430 Display a row/column ruler on the colon command line.
2431 .It Cm scroll , scr Bq "window size / 2"
2432 Set the number of lines scrolled.
2433 .It Cm searchincr Bq off
2434 Makes the
2435 .Cm /
2436 and
2437 .Cm ?\&
2438 commands incremental.
2439 .It Cm sections , sect Bq "NHSHH HUnhsh"
2440 .Nm vi
2441 only.
2442 Define additional section boundaries for the
2443 .Cm [[
2444 and
2445 .Cm ]]
2446 commands.
2447 .It Cm secure Bq off
2448 Turns off all access to external programs.
2449 .It Cm shell , sh Bq "environment variable SHELL, or /bin/sh"
2450 Select the shell used by the editor.
2451 .It Cm shellmeta Bq ~{[*?$`'\&"\e
2452 Set the meta characters checked to determine if file name expansion
2453 is necessary.
2454 .It Cm shiftwidth , sw Bq 8
2455 Set the autoindent and shift command indentation width.
2456 .It Cm showmatch , sm Bq off
2457 .Nm vi
2458 only.
2459 Note the left matching characters when the right ones are inserted.
2460 .It Cm showmode , smd Bq off
2461 .Nm vi
2462 only.
2463 Display the current editor mode and a
2464 .Dq modified
2465 flag.
2466 .It Cm sidescroll Bq 16
2467 .Nm vi
2468 only.
2469 Set the amount a left-right scroll will shift.
2470 .It Cm slowopen , slow Bq off
2471 Delay display updating during text input.
2472 This option is not yet implemented.
2473 .It Cm sourceany Bq off
2474 Read startup files not owned by the current user.
2475 This option will never be implemented.
2476 .It Cm tabstop , ts Bq 8
2477 This option sets tab widths for the editor display.
2478 .It Cm taglength , tl Bq 0
2479 Set the number of significant characters in tag names.
2480 .It Cm tags , tag Bq tags
2481 Set the list of tags files.
2482 .It Xo
2483 .Cm term , ttytype , tty
2484 .Bq "environment variable TERM"
2485 .Xc
2486 Set the terminal type.
2487 .It Cm terse Bq off
2488 This option has historically made editor messages less verbose.
2489 It has no effect in this implementation.
2490 .It Cm tildeop Bq off
2491 Modify the
2492 .Cm ~
2493 command to take an associated motion.
2494 .It Cm timeout , to Bq on
2495 Time out on keys which may be mapped.
2496 .It Cm ttywerase Bq off
2497 .Nm vi
2498 only.
2499 Select an alternate erase algorithm.
2500 .It Cm verbose Bq off
2501 .Nm vi
2502 only.
2503 Display an error message for every error.
2504 .It Cm w300 Bq no default
2505 .Nm vi
2506 only.
2507 Set the window size if the baud rate is less than 1200 baud.
2508 .It Cm w1200 Bq no default
2509 .Nm vi
2510 only.
2511 Set the window size if the baud rate is equal to 1200 baud.
2512 .It Cm w9600 Bq no default
2513 .Nm vi
2514 only.
2515 Set the window size if the baud rate is greater than 1200 baud.
2516 .It Cm warn Bq on
2517 .Nm ex
2518 only.
2519 This option causes a warning message to be printed on the terminal
2520 if the file has been modified since it was last written, before a
2521 .Cm !\&
2522 command.
2523 .It Xo
2524 .Cm window , w , wi
2525 .Bq "environment variable LINES \- 1"
2526 .Xc
2527 Set the window size for the screen.
2528 .It Cm windowname Bq off
2529 Change the icon/window name to the current file name.
2530 .It Cm wraplen , wl Bq 0
2531 .Nm vi
2532 only.
2533 Break lines automatically,
2534 the specified number of columns from the left-hand margin.
2535 If both the
2536 .Cm wraplen
2537 and
2538 .Cm wrapmargin
2539 edit options are set, the
2540 .Cm wrapmargin
2541 value is used.
2542 .It Cm wrapmargin , wm Bq 0
2543 .Nm vi
2544 only.
2545 Break lines automatically,
2546 the specified number of columns from the right-hand margin.
2547 If both the
2548 .Cm wraplen
2549 and
2550 .Cm wrapmargin
2551 edit options are set, the
2552 .Cm wrapmargin
2553 value is used.
2554 .It Cm wrapscan , ws Bq on
2555 Set searches to wrap around the end or beginning of the file.
2556 .It Cm writeany , wa Bq off
2557 Turn off file-overwriting checks.
2558 .El
2559 .Sh ENVIRONMENT
2560 .Bl -tag -width "COLUMNS"
2561 .It Ev COLUMNS
2562 The number of columns on the screen.
2563 This value overrides any system or terminal specific values.
2564 If the
2565 .Ev COLUMNS
2566 environment variable is not set when
2567 .Nm ex Ns / Ns Nm vi
2568 runs, or the
2569 .Cm columns
2570 option is explicitly reset by the user,
2571 .Nm ex Ns / Ns Nm vi
2572 enters the value into the environment.
2573 .It Ev EXINIT
2574 A list of
2575 .Nm ex
2576 startup commands, read after
2577 .Pa /etc/vi.exrc
2578 unless the variable
2579 .Ev NEXINIT
2580 is also set.
2581 .It Ev HOME
2582 The user's home directory, used as the initial directory path for the startup
2583 .Pa $HOME/.nexrc
2584 and
2585 .Pa $HOME/.exrc
2586 files.
2587 This value is also used as the default directory for the
2588 .Cm cd
2589 command.
2590 .It Ev LINES
2591 The number of rows on the screen.
2592 This value overrides any system or terminal specific values.
2593 If the
2594 .Ev LINES
2595 environment variable is not set when
2596 .Nm ex Ns / Ns Nm vi
2597 runs, or the
2598 .Cm lines
2599 option is explicitly reset by the user,
2600 .Nm ex Ns / Ns Nm vi
2601 enters the value into the environment.
2602 .It Ev NEXINIT
2603 A list of
2604 .Nm ex
2605 startup commands, read after
2606 .Pa /etc/vi.exrc .
2607 .It Ev SHELL
2608 The user's shell of choice
2609 .Pq see also the Cm shell No option .
2610 .It Ev TERM
2611 The user's terminal type.
2612 The default is the type
2613 .Dq unknown .
2614 If the
2615 .Ev TERM
2616 environment variable is not set when
2617 .Nm ex Ns / Ns Nm vi
2618 runs, or the
2619 .Cm term
2620 option is explicitly reset by the user,
2621 .Nm ex Ns / Ns Nm vi
2622 enters the value into the environment.
2623 .It Ev TMPDIR
2624 The location used to store temporary files
2625 .Pq see also the Cm directory No edit option .
2626 .El
2627 .Sh ASYNCHRONOUS EVENTS
2628 .Bl -tag -width "SIGWINCH" -compact
2629 .It Dv SIGALRM
2630 .Nm vi Ns / Ns Nm ex
2631 uses this signal for periodic backups of file modifications and to display
2632 .Dq busy
2633 messages when operations are likely to take a long time.
2634 .Pp
2635 .It Dv SIGHUP
2636 .It Dv SIGTERM
2637 If the current buffer has changed since it was last written in its entirety,
2638 the editor attempts to save the modified file so it can be later recovered.
2639 See the
2640 .Nm vi Ns / Ns Nm ex
2641 reference manual section
2642 .Sx Recovery
2643 for more information.
2644 .Pp
2645 .It Dv SIGINT
2646 When an interrupt occurs, the current operation is halted
2647 and the editor returns to the command level.
2648 If interrupted during text input,
2649 the text already input is resolved into the file as if the text
2650 input had been normally terminated.
2651 .Pp
2652 .It Dv SIGWINCH
2653 The screen is resized.
2654 See the
2655 .Nm vi Ns / Ns Nm ex
2656 reference manual section
2657 .Sx Sizing the Screen
2658 for more information.
2659 .\" .Pp
2660 .\" .It Dv SIGCONT
2661 .\" .It Dv SIGTSTP
2662 .\" .Nm vi Ns / Ns Nm ex
2663 .\" ignores these signals.
2664 .El
2665 .Sh FILES
2666 .Bl -tag -width "/var/tmp/vi.recover"
2667 .It Pa /bin/sh
2668 The default user shell.
2669 .It Pa /etc/vi.exrc
2670 System-wide
2671 .Nm vi
2672 startup file.
2673 It is read for
2674 .Nm ex
2675 commands first in the startup sequence.
2676 Must be owned by root or the user,
2677 and writable only by the owner.
2678 .It Pa /tmp
2679 Temporary file directory.
2680 .It Pa /var/tmp/vi.recover
2681 The default recovery file directory.
2682 .It Pa $HOME/.nexrc
2683 First choice for user's home directory startup file, read for
2684 .Nm ex
2685 commands right after
2686 .Pa /etc/vi.exrc
2687 unless either
2688 .Ev NEXINIT
2689 or
2690 .Ev EXINIT
2691 are set.
2692 Must be owned by root or the user,
2693 and writable only by the owner.
2694 .It Pa $HOME/.exrc
2695 Second choice for user's home directory startup file, read for
2696 .Nm ex
2697 commands under the same conditions as
2698 .Pa $HOME/.nexrc .
2699 .It Pa .nexrc
2700 First choice for local directory startup file, read for
2701 .Nm ex
2702 commands at the end of the startup sequence if the
2703 .Cm exrc
2704 option was turned on earlier.
2705 Must be owned by the user
2706 and writable only by the owner.
2707 .It Pa .exrc
2708 Second choice for local directory startup file, read for
2709 .Nm ex
2710 commands under the same conditions as
2711 .Pa .nexrc .
2712 .El
2713 .Sh EXIT STATUS
2714 The
2715 .Nm ex
2716 and
2717 .Nm vi
2718 utilities exit 0 on success,
2719 and \*(Gt0 if an error occurs.
2720 .Sh SEE ALSO
2721 .Xr ctags 1 ,
2722 .Xr iconv 1 ,
2723 .Xr re_format 7
2724 .Sh STANDARDS
2725 .Nm nex Ns / Ns Nm nvi
2726 is close to
2727 .St -p1003.1-2008 .
2728 That document differs from historical
2729 .Nm ex Ns / Ns Nm vi
2730 practice in several places; there are changes to be made on both sides.
2731 .Sh HISTORY
2732 The
2733 .Nm ex
2734 editor first appeared in
2735 .Bx 1 .
2736 The
2737 .Nm nex Ns / Ns Nm nvi
2738 replacements for the
2739 .Nm ex Ns / Ns Nm vi
2740 editor first appeared in
2741 .Bx 4.4 .
2742 .Sh AUTHORS
2743 .An Bill Joy
2744 wrote the original version of
2745 .Nm ex
2746 in 1977.