Debian Codegraph @

upstream/debian-unstable/man1/nvi.1

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