document vsplit
[nvi.git] / docs / vi.ref / ex.cmd.texi
blob446f4b6b77726d4a0eaa4e6ab667a98976981881
1 @comment  Copyright (c) 1994
2 @comment        The Regents of the University of California.  All rights reserved.
3 @comment  Copyright (c) 1994, 1995, 1996
4 @comment        Keith Bostic.  All rights reserved.
5 @comment 
6 @comment  See the LICENSE file for redistribution information.
7 @comment 
8 @comment        $Id: ex.cmd.texi,v 8.2 2001/08/20 16:05:50 skimo Exp $ (Berkeley) $Date: 2001/08/20 16:05:50 $
9 @comment 
10 @chapter Ex Description
12 The following words have special meanings for
13 @CO{ex}
14 commands.
15 @itemize @bullet
16 @cindex "<end-of-file>"
17 @IP{<end-of-file>}
19 The end-of-file character is used to scroll the screen in the
20 @CO{ex}
21 editor.
22 This character is normally
23 @LI{<control-D>}.
24 However, whatever character is set for the current terminal is supported
25 as well as
26 @LI{<control-D>}.
27 @cindex "line"
28 @IP{line}
30 A single-line address, given in any of the forms described in the
31 section entitled
32 @QB{Ex Addressing} .
33 The default for
34 @LI{line}is the current line.
35 @cindex "range"
36 @IP{range}
38 A line, or a pair of line addresses, separated by a comma or semicolon.
39 (See the section entitled
40 @QB{Ex Addressing}
41 for more information.)
42 The default for range is the current line
43 @emph{only},
44 i.e.
45 @QT{.,.}.
46 A percent sign
47 @PQ{%}
48 stands for the range
49 @QT{1,$}.
50 The starting address must be less than, or equal to, the ending address.
51 @cindex "count"
52 @IP{count}
54 A positive integer, specifying the number of lines to be affected by
55 the command; the default is 1.
56 Generally, a count past the end-of-file may be specified, e.g. the
57 command
58 @QT{p 3000}
59 in a 10 line file is acceptable, and will print from the current line
60 through the last line in the file.
61 @cindex "flags"
62 @IP{flags}
64 One or more of the characters
65 @QQ{#},
66 @QQ{p},
67 and
68 @QQ{l}.
69 When a command that accepts these flags completes, the addressed line(s)
70 are written out as if by the corresponding
71 @CO{#},
72 @CO{l}
74 @CO{p}
75 commands.
76 In addition, any number of
77 @QT{+}
79 @QT{-}
80 characters can be specified before, after, or during the flags, in which
81 case the line written is not necessarily the one affected by the command,
82 but rather the line addressed by the offset address specified.
83 The default for
84 @LI{flags}is none.
85 @cindex "file"
86 @IP{file}
88 A pattern used to derive a pathname; the default is the current file.
89 File names are subjected to normal
90 @XR{sh,1}
91 word expansions.
92 @end itemize
94 Anywhere a file name is specified, it is also possible to use
95 the special string
96 @QT{/tmp}.
97 This will be replaced with a temporary file name which can be used
98 for temporary work, e.g.
99 @QT{:e /tmp}
100 creates and edits a new file.
102 If both a count and a range are specified for commands that use either,
103 the starting line for the command is the
104 @emph{last}
105 line addressed by the range, and
106 @LI{count}- 1
107 subsequent lines are affected by the command, e.g. the command
108 @QT{2,3p4}
109 prints out lines 3, 4, 5 and 6.
111 When only a line or range is specified, with no command, the implied
112 command is either a
113 @CO{list},
114 @CO{number}
116 @CO{print}
117 command.
118 The command used is the most recent of the three commands to have been
119 used (including any use as a flag).
120 If none of these commands have been used before, the
121 @CO{print}
122 command is the implied command.
123 When no range or count is specified and the command line is a blank line,
124 the current line is incremented by 1 and then the current line is displayed.
126 Zero or more whitespace characters may precede or follow the addresses,
127 count, flags, or command name.
128 Any object following a command name (such as buffer, file, etc.),
129 that begins with an alphabetic character,
130 should be separated from the command name by at least one whitespace
131 character.
133 Any character, including
134 @LI{<carriage-return>},
135 @QT{%}
137 @QT{#}
138 retain their literal value when preceded by a backslash.
139 @chapter Ex Commands
141 The following section describes the commands available in the
142 @CO{ex}
143 editor.
144 In each entry below, the tag line is a usage synopsis for the command.
146 Each command can be entered as the abbreviation
147 (those characters in the synopsis command word preceding the
148 @QQ{[}
149 character),
150 the full command (all characters shown for the command word,
151 omitting the
152 @QQ{[}
154 @QQ{]}
155 characters),
156 or any leading subset of the full command down to the abbreviation.
157 For example, the args command (shown as
158 @QT{ar[gs]}
159 in the synopsis)
160 can be entered as
161 @QT{ar},
162 @QT{arg}
164 @QT{args}.
166 Each
167 @CO{ex}
168 command described below notes the new current line after it
169 is executed, as well as any options that affect the command.
170 @cindex DOUBLEQUOTE
171 @deftypefn Command {} {"}
173 A comment.
174 Command lines beginning with the double-quote character
175 @PQ{"}
176 are ignored.
177 This permits comments in editor scripts and startup files.
178 @end deftypefn
179 @cindex "<control-D>"
180 @cindex "<end-of-file>"
181 @deftypefn Command {} {<control-D>}
183 @deftypefnx Command {} {<end-of-file>}
185 Scroll the screen.
186 Write the next N lines, where N is the value of the
187 @OP{scroll}
188 option.
189 The command is the end-of-file terminal character, which may be
190 different on different terminals.
191 Traditionally, it is the
192 @LI{<control-D>}key.
193 @sp 1
194 Historically, the
195 @CO{eof}
196 command ignored any preceding count, and the
197 @LI{<end-of-file>}character was ignored unless it was entered as the first character
198 of the command.
199 This implementation treats it as a command
200 @emph{only}
201 if entered as the first character of the command line, and otherwise
202 treats it as any other character.
203 @table @asis
204 @item Line:
205 Set to the last line written.
206 @item Options:
207 Affected by the
208 @OP{scroll}
209 option.
210 @end table
211 @end deftypefn
212 @cindex "!"
213 @deftypefn Command {} {!} {argument(s)}
215 @deftypefnx Command {}  {[range]!} {argument(s)}
216 Execute a shell command, or filter lines through a shell command.
217 In the first synopsis, the remainder of the line after the
218 @QT{!}
219 character is passed to the program named by the
220 @OP{shell}
221 option, as a single argument.
222 @sp 1
223 Within the rest of the line,
224 @QT{%}
226 @QT{#}
227 are expanded into the current and alternate pathnames, respectively.
228 The character
229 @QT{!}
230 is expanded with the command text of the previous
231 @CO{!}
232 command.
233 (Therefore, the command
234 @CO{!!}
235 repeats the previous
236 @CO{!}
237 command.)
238 The special meanings of
239 @QT{%},
240 @QT{#},
242 @QT{!}
243 can be overridden by escaping them with a backslash.
244 If no
245 @CO{!}
247 @CO{:!}
248 command has yet been executed, it is an error to use an unescaped
249 @QT{!}
250 character.
252 @CO{!}
253 command does
254 @emph{not}
255 do shell expansion on the strings provided as arguments.
256 If any of the above expansions change the command the user entered,
257 the command is redisplayed at the bottom of the screen.
258 @sp 1
259 @CO{Ex}
260 then executes the program named by the
261 @OP{shell}
262 option, with a
263 @strong{-c}
264 flag followed by the arguments (which are bundled into a single argument).
265 @sp 1
267 @CO{!}
268 command is permitted in an empty file.
269 @sp 1
270 If the file has been modified since it was last completely written,
272 @CO{!}
273 command will warn you.
274 @sp 1
275 A single
276 @QT{!}
277 character is displayed when the command completes.
278 @sp 1
279 In the second form of the
280 @CO{!}
281 command, the remainder of the line after the
282 @QT{!}
283 is passed to the program named by the
284 @OP{shell}
285 option, as described above.
286 The specified lines are passed to the program as standard input,
287 and the standard and standard error output of the program replace
288 the original lines.
289 @table @asis
290 @item Line:
291 Unchanged if no range was specified, otherwise set to the first
292 line of the range.
293 @item Options:
294 Affected by the
295 @OP{shell}
297 @OP{warn}
298 options.
299 @end table
300 @end deftypefn
301 @cindex "#"
302 @deftypefn Command {[range]} {#} {[count] [flags]}
304 @cindex "number"
305 @deftypefnx Command  {[range]} {nu[mber]} {[count] [flags]}
306 Display the selected lines, each preceded with its line number.
307 @sp 1
308 The line number format is
309 @QQ{%6d},
310 followed by two spaces.
311 @table @asis
312 @item Line:
313 Set to the last line displayed.
314 @item Options:
315 Affected by the
316 @OP{list}
317 option.
318 @end table
319 @end deftypefn
320 @cindex "@@"
321 @deftypefn Command {@@} {buffer}
323 @cindex "*"
324 @deftypefnx Command {}  {*} {buffer}
325 Execute a buffer.
326 Each line in the named buffer is executed as an
327 @CO{ex}
328 command.
329 If no buffer is specified, or if the specified buffer is
330 @QT{@@}
332 @QT{*},
333 the last buffer executed is used.
334 @end deftypefn
335 @cindex <
336 @deftypefn Command {[range]} {<[< ...]} {[count] [flags]}
338 Shift lines left or right.
339 The specified lines are shifted to the left (for the
340 @CO{<}
341 command) or right (for the
342 @CO{>}
343 command), by the number of columns specified by the
344 @OP{shiftwidth}
345 option.
346 Only leading whitespace characters are deleted when shifting left;
347 once the first column of the line contains a nonblank character,
349 @CO{shift}
350 command will succeed, but the line will not be modified.
351 @sp 1
352 If the command character
353 @CO{<}
355 @CO{>}
356 is repeated more than once, the command is repeated once for each
357 additional command character.
358 @table @asis
359 @item Line:
360 If the current line is set to one of the lines that are affected
361 by the command, it is unchanged.
362 Otherwise, it is set to the first nonblank character of the lowest
363 numbered line shifted.
364 @item Options:
365 Affected by the
366 @OP{shiftwidth}
367 option.
368 @end table
369 @end deftypefn
370 @cindex =
371 @deftypefn Command {[line]} {=} {[flags]}
373 Display the line number of
374 @LI{line}(which defaults to the last line in the file).
375 @table @asis
376 @item Line:
377 Unchanged.
378 @item Options:
379 None.
380 @end table
381 @end deftypefn
382 @cindex >
383 @deftypefn Command {[range]} {>[> ...]} {[count] [flags]}
385 Shift right.
386 The specified lines are shifted to the right by the number of columns
387 specified by the
388 @OP{shiftwidth}
389 option, by inserting tab and space characters.
390 Empty lines are not changed.
391 @sp 1
392 If the command character
393 @QT{>}
394 is repeated more than once, the command is repeated once for each
395 additional command character.
396 @table @asis
397 @item Line:
398 Set to the last line modified by the command.
399 @item Options:
400 Affected by the
401 @OP{shiftwidth}
402 option.
403 @end table
404 @end deftypefn
405 @cindex abbrev
406 @deftypefn Command {} {ab[brev]} {lhs rhs}
408 Add an abbreviation to the current abbreviation list.
409 When inserting text in
410 @CO{vi},
411 each time a non-word character is entered after a word character,
412 a set of characters ending at the word character are checked for
413 a match with
414 @LI{lhs}.
415 If a match is found, they are replaced with
416 @LI{rhs}.
417 The set of characters that are checked for a match are defined as follows,
418 for inexplicable historical reasons.
419 If only one or two characters were entered before the non-word character
420 that triggered the check,
421 and after the beginning of the insertion,
422 or the beginning of the line or the file,
423 or the last
424 @LI{<blank>}character that was entered,
425 then the one or the both characters are checked for a match.
426 Otherwise, the set includes both characters,
427 as well as the characters that precede them that are the same word
428 class (i.e. word or non-word) as the
429 @strong{second}
430 to last character entered before the non-word character that triggered
431 the check,
432 back to the first
433 @LI{<blank>}character,
434 the beginning of the insertion,
435 or the beginning of the line or the file.
436 @sp 1
437 For example, the abbreviations:
438 @sp 1
439 @multitable {:abbreviate} {/*#i} {/********************}
440 @item :abbreviate @tab abc @tab ABC
441 @item :abbreviate @tab #i @tab #include
442 @item :abbreviate @tab /*#i @tab /*#include
443 @end multitable
444 will all work, while the abbreviations:
445 @sp 1
446 @multitable {:abbreviate} {/*#i} {/********************}
447 @item :abbreviate @tab a#i @tab A#include
448 @item :abbreviate @tab /* @tab /********************
449 @end multitable
450 will not work, and are not permitted by
451 @CO{nvi}.
452 @sp 1
453 To keep the abbreviation expansion from happening,
454 the character immediately following the
455 @LI{lhs}characters should be quoted with a
456 @LI{<literal-next>}character.
457 @sp 1
458 The replacement
459 @LI{rhs}is itself subject to both further abbreviation expansion and further
460 map expansion.
461 @table @asis
462 @item Line:
463 Unchanged.
464 @item Options:
465 None.
466 @end table
467 @end deftypefn
468 @cindex append
469 @deftypefn Command {[line]} {a[ppend][!]}
471 The input text is appended to the specified line.
472 If line 0 is specified, the text is inserted at the beginning of the file.
473 Set to the last line input.
474 If no lines are input, then set to
475 @LI{line},
476 or to the first line of the file if a
477 @LI{line}of 0 was specified.
478 Following the command name with a
479 @QT{!}
480 character causes the
481 @OP{autoindent}
482 option to be toggled for the duration of the command.
483 @table @asis
484 @item Line:
485 Unchanged.
486 @item Options:
487 Affected by the
488 @OP{autoindent}
490 @OP{number}
491 options.
492 @end table
493 @end deftypefn
494 @cindex args
495 @deftypefn Command {} {ar[gs]}
497 Display the argument list.
498 The current argument is displayed inside of
499 @QT{[}
501 @QT{]}
502 characters.
503 The argument list is the list of operands specified on startup,
504 which can be replaced using the
505 @CO{next}
506 command.
507 @table @asis
508 @item Line:
509 Unchanged.
510 @item Options:
511 None.
512 @end table
513 @end deftypefn
514 @cindex bg
515 @deftypefn Command {} {bg}
517 @CO{Vi}
518 mode only.
519 Background the current screen.
520 The screen is unchanged,
521 but is no longer accessible and disappears from the display.
522 Use the
523 @CO{fg}
524 command to bring the screen back to the display foreground.
525 @table @asis
526 @item Line:
527 Set to the current line when the screen was last edited.
528 @item Options:
529 None.
530 @end table
531 @end deftypefn
532 @cindex change
533 @deftypefn Command {[range]} {c[hange][!]} {[count]}
535 Replace the lines with input text.
536 Following the command name with a
537 @QT{!}
538 character causes the
539 @OP{autoindent}
540 option to be toggled for the duration of the command.
541 @table @asis
542 @item Line:
543 Set to the last line input, or, if no lines were input,
544 set to the line before the target line, or to the first
545 line of the file if there are no lines preceding the target line.
546 @item Options:
547 Affected by the
548 @OP{autoindent}
550 @OP{number}
551 options.
552 @end table
553 @cindex cd
554 @end deftypefn
555 @cindex chdir
556 @deftypefn Command {} {chd[ir][!]} {[directory]}
558 @deftypefnx Command {}  {cd[!]} {[directory]}
559 Change the current working directory.
561 @LI{directory}argument is subjected to
562 @XR{sh,1}
563 word expansions.
564 When invoked with no directory argument and the
565 @LI{HOME}environment variable is set, the directory named by the
566 @LI{HOME}environment variable becomes the new current directory.
567 Otherwise, the new current directory becomes the directory returned
568 by the
569 @XR{getpwent,3}
570 routine.
571 @sp 1
573 @CO{chdir}
574 command will fail if the file has been modified since the last complete
575 write of the file.
576 You can override this check by appending a
577 @QT{!}
578 character to the command.
579 @table @asis
580 @item Line:
581 Unchanged.
582 @item Options:
583 Affected by the
584 @OP{cdpath}
585 option.
586 @end table
587 @cindex copy
588 @end deftypefn
589 @cindex t
590 @deftypefn Command {[range]} {co[py]} {line [flags]}
592 @deftypefnx Command  {[range]} {t} {line [flags]}
593 Copy the specified lines (range) after the destination line.
594 Line 0 may be specified to insert the lines at the beginning of
595 the file.
596 @table @asis
597 @item Line:
598 Unchanged.
599 @item Options:
600 None.
601 @end table
602 @end deftypefn
603 @cindex cscope
604 @deftypefn Command {} {cs[cope]} {command [args]}
606 Execute a
607 @CO{cscope}
608 command.
609 For more information, see the section of the reference manual entitled
610 @QB{Tags, Tag Stacks, and Cscope} .
611 @end deftypefn
612 @cindex delete
613 @deftypefn Command {[range]} {d[elete]} {[buffer] [count] [flags]}
615 Delete the lines from the file.
616 The deleted text is saved in the specified buffer, or, if no buffer
617 is specified, in the unnamed buffer.
618 If the command name is followed by a letter that could be interpreted
619 as either a buffer name or a flag value (because neither a
620 @LI{count}or
621 @LI{flags}values were given),
622 @CO{ex}
623 treats the letter as a
624 @LI{flags}value if the letter immediately follows the command name,
625 without any whitespace separation.
626 If the letter is preceded by whitespace characters,
627 it treats it as a buffer name.
628 @table @asis
629 @item Line:
630 Set to the line following the deleted lines,
631 or to the last line if the deleted lines were at the end.
632 @item Options:
633 None.
634 @end table
635 @end deftypefn
636 @cindex display
637 @deftypefn Command {} {di[splay]} {b[uffers] | c[onnections] | s[creens] | t[ags]}
639 Display buffers,
640 @CO{cscope}
641 connections, screens or tags.
643 @CO{display}
644 command takes one of three additional arguments, which are as follows:
645 @table @asis
646 @item b[uffers]
647 Display all buffers (including named, unnamed, and numeric)
648 that contain text.
649 @item c[onnections]
650 Display the source directories for all attached
651 @CO{cscope}
652 databases.
653 @item s[creens]
654 Display the file names of all background screens.
655 @item t[ags]
656 Display the tags stack.
657 @end table
658 @table @asis
659 @item Line:
660 Unchanged.
661 @item Options:
662 None.
663 @end table
664 @end deftypefn
665 @cindex edit
666 @deftypefn Command {} {e[dit][!]} {[+cmd] [file]}
667 @deftypefnx Command {}  {ex[!]} {[+cmd] [file]}
668 @deftypefnx Command {} {vs[plit][!]} {[+cmd] [file]}
669 Edit a different file.
670 If the current buffer has been modified since the last complete write,
671 the command will fail.
672 You can override this by appending a
673 @QT{!}
674 character to the command name.
675 @sp 1
676 If the
677 @QT{+cmd}
678 option is specified, that
679 @CO{ex}
680 command will be executed in the new file.
682 @CO{ex}
683 command may be used, although the most common use of this feature is
684 to specify a line number or search pattern to set the initial location
685 in the new file.
686 @sp 1
687 Capitalizing the first letter of the command, i.e.,
688 @CO{Edit}
690 @CO{Ex},
691 while in
692 @CO{vi}
693 mode, will edit the file in a new screen.
694 In this case, any modifications to the current file are ignored.
695 @cindex vertical split
696 @cindex splitting, vertically
697 @CO{vsplit} is similar, but the screen will be split vertically
698 to produce the new screen, rather than horizontally.
700 @table @asis
701 @item Line:
702 If you have previously edited the file, the current line will be set
703 to your last position in the file.
704 If that position does not exist, or you have not previously edited the
705 file, the current line will be set to the first line of the file if
706 you are in
707 @CO{vi}
708 mode, and the last line of the file if you are in
709 @CO{ex}.
710 @item Options:
711 None.
712 @end table
713 @end deftypefn
714 @cindex exusage
715 @deftypefn Command {} {exu[sage]} {[command]}
717 Display usage for an
718 @CO{ex}
719 command.
721 @LI{command}is specified, a usage statement for that command is displayed.
722 Otherwise, usage statements for all
723 @CO{ex}
724 commands are displayed.
725 @table @asis
726 @item Line:
727 Unchanged.
728 @item Options:
729 None.
730 @end table
731 @end deftypefn
732 @cindex file
733 @deftypefn Command {} {f[ile]} {[file]}
735 Display and optionally change the file name.
736 If a file name is specified, the current pathname is changed to the
737 specified name.
738 The current pathname, the number of lines, and the current position
739 in the file are displayed.
740 @table @asis
741 @item Line:
742 Unchanged.
743 @item Options:
744 None.
745 @end table
746 @end deftypefn
747 @cindex fg
748 @deftypefn Command {} {fg} {[name]}
750 @CO{Vi}
751 mode only.
752 Foreground the specified screen.
753 If the argument name doesn't exactly match the name of a file displayed
754 by a background screen,
755 it is compared against the last component of each of the file names.
756 If no background screen is specified,
757 the first background screen is foregrounded.
758 @sp 1
759 By default,
760 foregrounding causes the current screen to be swapped with the backgrounded
761 screen.
762 Capitalizing the first letter of the command, i.e.
763 @CO{Fg},
764 will foreground the backgrounded screen in a new screen instead of
765 swapping it with the current screen.
766 @table @asis
767 @item Line:
768 Set to the current line when the screen was last edited.
769 @item Options:
770 None.
771 @end table
772 @end deftypefn
773 @cindex global
774 @deftypefn Command {[range]} {g[lobal]} {/pattern/ [commands]}
776 @cindex v
777 @deftypefnx Command  {[range]} {v} {/pattern/ [commands]}
778 Apply commands to lines matching (or not matching) a pattern.
779 The lines within the given range that match
780 @PQ{g[lobal]},
781 or do not match
782 @PQ{v}
783 the given pattern are selected.
784 Then, the specified
785 @CO{ex}
786 command(s) are executed with the current line
787 @PQ{.}
788 set to each selected line.
789 If no range is specified, the entire file is searched for matching,
790 or not matching, lines.
791 @sp 1
792 Multiple commands can be specified, one per line, by escaping each
793 @LI{<newline>}character with a backslash, or by separating commands with a
794 @QT{|}
795 character.
796 If no commands are specified, the command defaults to the
797 @CO{print}
798 command.
799 @sp 1
800 For the
801 @CO{append},
802 @CO{change}
804 @CO{insert}
805 commands, the input text must be part of the global command line.
806 In this case, the terminating period can be omitted if it ends the commands.
807 @sp 1
809 @CO{visual}
810 command may also be specified as one of the
811 @CO{ex}
812 commands.
813 In this mode, input is taken from the terminal.
814 Entering a
815 @CO{Q}
816 command in
817 @CO{vi}
818 mode causes the next line matching the pattern to be selected and
819 @CO{vi}
820 to be reentered, until the list is exhausted.
821 @sp 1
823 @CO{global},
824 @CO{v}
826 @CO{undo}
827 commands cannot be used as part of these commands.
828 @sp 1
829 The editor options
830 @OP{autoindent},
831 @OP{autoprint}
833 @OP{report}
834 are turned off for the duration of the
835 @CO{global}
837 @CO{v}
838 commands.
839 @table @asis
840 @item Line:
841 The last line modified.
842 @item Options:
843 Affected by the
844 @OP{ignorecase}
846 @OP{magic}
847 options.
848 Turns off the
849 @OP{autoindent},
850 @OP{autoprint}
852 @OP{report}
853 options.
854 @end table
855 @end deftypefn
856 @cindex help
857 @deftypefn Command {} {he[lp]}
859 Display a help message.
860 @table @asis
861 @item Line:
862 Unchanged.
863 @item Options:
864 None.
865 @end table
866 @end deftypefn
867 @cindex insert
868 @deftypefn Command {[line]} {i[nsert][!]}
870 The input text is inserted before the specified line.
871 Following the command name with a
872 @QT{!}
873 character causes the
874 @OP{autoindent}
875 option setting to be toggled for the duration of this command.
876 @table @asis
877 @item Line:
878 Set to the last line input; if no lines were input,
879 set to the line before the target line, or to the first line
880 of the file if there are no lines preceding the target line.
881 Affected by the
882 @OP{autoindent}
884 @OP{number}
885 options.
886 @end table
887 @end deftypefn
888 @cindex join
889 @deftypefn Command {[range]} {j[oin][!]} {[count] [flags]}
891 Join lines of text together.
892 @sp 1
894 @LI{count}specified to the
895 @CO{join}
896 command specifies that the last line of the
897 @LI{range}plus
898 @LI{count}subsequent lines will be joined.
899 (Note, this differs by one from the general rule where only
900 @LI{count}- 1
901 subsequent lines are affected.)
902 @sp 1
903 If the current line ends with a whitespace character, all whitespace
904 is stripped from the next line.
905 Otherwise, if the next line starts with a open parenthesis
906 @PQ{(},
907 do nothing.
908 Otherwise, if the current line ends with a question mark
909 @PQ{?},
910 period
911 @PQ{.}
912 or exclamation point
913 @PQ{!},
914 insert two spaces.
915 Otherwise, insert a single space.
916 @sp 1
917 Appending a
918 @QT{!}
919 character to the command name causes a simpler join with no
920 white-space processing.
921 @table @asis
922 @item Line:
923 Unchanged.
924 @item Options:
925 None.
926 @end table
927 @end deftypefn
928 @cindex list
929 @deftypefn Command {[range]} {l[ist]} {[count] [flags]}
931 Display the lines unambiguously.
932 Tabs are displayed as
933 @QT{^I},
934 and the end of the line is marked with a
935 @QT{$}
936 character.
937 @table @asis
938 @item Line:
939 Set to the last line displayed.
940 @item Options:
941 Affected by the
942 @OP{number}
943 option.
944 @end table
945 @end deftypefn
946 @cindex map
947 @deftypefn Command {} {map[!]} {[lhs rhs]}
949 Define or display maps (for
950 @CO{vi}
951 only).
952 @sp 1
954 @QT{lhs}
956 @QT{rhs}
957 are not specified, the current set of command mode maps are displayed.
958 If a
959 @QT{!}
960 character is appended to to the command,
961 the text input mode maps are displayed.
962 @sp 1
963 Otherwise, when the
964 @QT{lhs}
965 character sequence is entered in
966 @CO{vi},
967 the action is as if the corresponding
968 @QT{rhs}
969 had been entered.
970 If a
971 @QT{!}
972 character is appended to the command name,
973 the mapping is effective during text input mode,
974 otherwise, it is effective during command mode.
975 This allows
976 @QT{lhs}
977 to have two different macro definitions at the same time: one for command
978 mode and one for input mode.
979 @sp 1
980 Whitespace characters require escaping with a
981 @LI{<literal-next>}character to be entered in the
982 @LI{lhs}string in visual mode.
983 @sp 1
984 Normally, keys in the
985 @LI{rhs}string are remapped (see the
986 @OP{remap}
987 option),
988 and it is possible to create infinite loops.
989 However, keys which map to themselves are not further remapped,
990 regardless of the setting of the
991 @OP{remap}
992 option.
993 For example, the command
994 @QT{:map n nz.}
995 maps the
996 @QT{n}
997 key to the
998 @CO{n}
1000 @CO{z}
1001 commands.
1002 @sp 1
1003 To exit an infinitely looping map, use the terminal
1004 @LI{<interrupt>}character.
1005 @table @asis
1006 @item Line:
1007 Unchanged.
1008 @item Options:
1009 Affected by the
1010 @OP{remap}
1011 option.
1012 @end table
1013 @cindex mark
1014 @end deftypefn
1015 @cindex k
1016 @deftypefn Command {[line]} {ma[rk]} {<character>}
1018 @deftypefnx Command  {[line]} {k} {<character>}
1019 Mark the line with the mark
1020 @LI{<character>}.
1021 The expressions
1022 @QT{'<character>}
1024 @QT{`<character>}
1025 can then be used as an address in any command that uses one.
1026 @table @asis
1027 @item Line:
1028 Unchanged.
1029 @item Options:
1030 None.
1031 @end table
1032 @end deftypefn
1033 @cindex move
1034 @deftypefn Command {[range]} {m[ove]} {line}
1036 Move the specified lines after the target line.
1037 A target line of 0 places the lines at the beginning of the file.
1038 @table @asis
1039 @item Line:
1040 Set to the first of the moved lines.
1041 @item Options:
1042 None.
1043 @end table
1044 @end deftypefn
1045 @cindex mkexrc
1046 @deftypefn Command {} {mk[exrc][!]} {file}
1048 Write the abbreviations, editor options and maps to the specified
1049 file.
1050 Information is written in a form which can later be read back in
1051 using the
1052 @CO{ex}
1053 @CO{source}
1054 command.
1056 @LI{file}already exists, the
1057 @CO{mkexrc}
1058 command will fail.
1059 This check can be overridden by appending a
1060 @QT{!}
1061 character to the command.
1062 @table @asis
1063 @item Line:
1064 Unchanged.
1065 @item Options:
1066 None.
1067 @end table
1068 @end deftypefn
1069 @cindex next
1070 @deftypefn Command {} {n[ext][!]} {[file ...]}
1072 Edit the next file from the argument list.
1074 @CO{next}
1075 command will fail if the file has been modified since the last complete
1076 write.
1077 This check can be overridden by appending the
1078 @QT{!}
1079 character to the command name.
1080 The argument list can optionally be replaced by specifying a new one
1081 as arguments to this command.
1082 In this case, editing starts with the first file on the new list.
1083 @sp 1
1084 Capitalizing the first letter of the command, i.e.
1085 @CO{Next},
1086 while in
1087 @CO{vi}
1088 mode, will set the argument list and edit the file in a new screen.
1089 In this case, any modifications to the current file are ignored.
1090 @table @asis
1091 @item Line:
1092 Set as described for the
1093 @CO{edit}
1094 command.
1095 @item Options:
1096 Affected by the options
1097 @OP{autowrite}
1099 @OP{writeany}.
1100 @end table
1101 @end deftypefn
1102 @cindex open
1103 @deftypefn Command {[line]} {o[pen]} {/pattern/ [flags]}
1105 Enter open mode.
1106 Open mode is the same as being in
1107 @CO{vi},
1108 but with a one-line window.
1109 All the standard
1110 @CO{vi}
1111 commands are available.
1112 If a match is found for the optional RE argument,
1113 the cursor is set to the start of the matching pattern.
1114 @sp 1
1115 @emph{This command is not yet implemented.}
1116 @table @asis
1117 @item Line:
1118 Unchanged, unless the optional RE is specified, in which case it is
1119 set to the line where the matching pattern is found.
1120 @item Options:
1121 Affected by the
1122 @OP{open}
1123 option.
1124 @end table
1125 @end deftypefn
1126 @cindex preserve
1127 @deftypefn Command {} {pre[serve]}
1129 Save the file in a form that can later be recovered using the
1130 @CO{ex}
1131 @strong{-r}
1132 option.
1133 When the file is preserved, an email message is sent to the user.
1134 @table @asis
1135 @item Line:
1136 Unchanged.
1137 @item Options:
1138 None.
1139 @end table
1140 @end deftypefn
1141 @cindex previous
1142 @deftypefn Command {} {prev[ious][!]}
1144 Edit the previous file from the argument list.
1146 @CO{previous}
1147 command will fail if the file has been modified since the last complete
1148 write.
1149 This check can be overridden by appending the
1150 @QT{!}
1151 character to the command name.
1152 @sp 1
1153 Capitalizing the first letter of the command, i.e.
1154 @CO{Previous},
1155 while in
1156 @CO{vi}
1157 mode, will edit the file in a new screen.
1158 In this case, any modifications to the current file are ignored.
1159 @table @asis
1160 @item Line:
1161 Set as described for the
1162 @CO{edit}
1163 command.
1164 @item Options:
1165 Affected by the options
1166 @OP{autowrite}
1168 @OP{writeany}.
1169 None.
1170 @end table
1171 @end deftypefn
1172 @cindex print
1173 @deftypefn Command {[range]} {p[rint]} {[count] [flags]}
1175 Display the specified lines.
1176 @table @asis
1177 @item Line:
1178 Set to the last line displayed.
1179 @item Options:
1180 Affected by the
1181 @OP{list}
1183 @OP{number}
1184 option.
1185 @end table
1186 @end deftypefn
1187 @cindex put
1188 @deftypefn Command {[line]} {pu[t]} {[buffer]}
1190 Append buffer contents to the current line.
1191 If a buffer is specified, its contents are appended to the line,
1192 otherwise, the contents of the unnamed buffer are used.
1193 @table @asis
1194 @item Line:
1195 Set to the line after the current line.
1196 @item Options:
1197 None.
1198 @end table
1199 @end deftypefn
1200 @cindex quit
1201 @deftypefn Command {} {q[uit][!]}
1203 End the editing session.
1204 If the file has been modified since the last complete write, the
1205 @CO{quit}
1206 command will fail.
1207 This check may be overridden by appending a
1208 @QT{!}
1209 character to the command.
1210 @sp 1
1211 If there are more files to edit, the
1212 @CO{quit}
1213 command will fail.
1214 Appending a
1215 @QT{!}
1216 character to the command name or entering two
1217 @CO{quit}
1218 commands (i.e.
1219 @CO{wq},
1220 @CO{quit},
1221 @CO{xit}
1223 @CO{ZZ})
1224 in a row) will override this check and the editor will exit.
1225 @table @asis
1226 @item Line:
1227 Unchanged.
1228 @item Options:
1229 None.
1230 @end table
1231 @end deftypefn
1232 @cindex read
1233 @deftypefn Command {[line]} {r[ead][!]} {[file]}
1235 Read a file.
1236 A copy of the specified file is appended to the line.
1238 @LI{line}is 0, the copy is inserted at the beginning of the file.
1239 If no file is specified, the current file is read; if there is no
1240 current file, then
1241 @LI{file}becomes the current file.
1242 If there is no current file and no
1243 @LI{file}is specified, then the
1244 @CO{read}
1245 command will fail.
1246 @sp 1
1248 @LI{file}is preceded by a
1249 @QT{!}
1250 character,
1251 @LI{file}is treated as if it were a shell command, and passed to the program
1252 named by the
1253 @OP{shell}
1254 edit option.
1255 The standard and standard error outputs of that command are read into
1256 the file after the specified line.
1257 The special meaning of the
1258 @QT{!}
1259 character can be overridden by escaping it with a backslash
1260 @PQ{\e}
1261 character.
1262 @table @asis
1263 @item Line:
1264 When executed from
1265 @CO{ex},
1266 the current line is set to the last line read.
1267 When executed from
1268 @CO{vi},
1269 the current line is set to the first line read.
1270 @item Options:
1271 None.
1272 @end table
1273 @end deftypefn
1274 @cindex recover
1275 @deftypefn Command {} {rec[over]} {file}
1277 Recover
1278 @LI{file}if it was previously saved.
1279 If no saved file by that name exists, the
1280 @CO{recover}
1281 command behaves equivalently to the
1282 @CO{edit}
1283 command.
1284 @table @asis
1285 @item Line:
1286 Set as described for the
1287 @CO{edit}
1288 command.
1289 @item Options:
1290 None.
1291 @end table
1292 @end deftypefn
1293 @cindex resize
1294 @deftypefn Command {} {res[ize]} {[+|-]size}
1296 @CO{Vi}
1297 mode only.
1298 Grow or shrink the current screen.
1300 @LI{size}is a positive, signed number, the current screen is grown by that many lines.
1302 @LI{size}is a negative, signed number, the current screen is shrunk by that many lines.
1304 @LI{size}is not signed, the current screen is set to the specified
1305 @LI{size}.
1306 Applicable only to split screens.
1307 @table @asis
1308 @item Line:
1309 Unchanged.
1310 @item Options:
1311 None.
1312 @end table
1313 @end deftypefn
1314 @cindex rewind
1315 @deftypefn Command {} {rew[ind][!]}
1317 Rewind the argument list.
1318 If the current file has been modified since the last complete write,
1320 @CO{rewind}
1321 command will fail.
1322 This check may be overridden by appending the
1323 @QT{!}
1324 character to the command.
1325 @sp 1
1326 Otherwise, the current file is set to the first file in the argument
1327 list.
1328 @table @asis
1329 @item Line:
1330 Set as described for the
1331 @CO{edit}
1332 command.
1333 @item Options:
1334 Affected by the
1335 @OP{autowrite}
1337 @OP{writeany}
1338 options.
1339 @end table
1340 @end deftypefn
1341 @cindex set
1342 @deftypefn Command {} {se[t]} {[option[=[value]] ...] [nooption ...] [option? ...] [all]}
1344 Display or set editor options.
1345 When no arguments are specified, the editor option
1346 @OP{term},
1347 and any editor options whose values have been changed from the
1348 default settings are displayed.
1349 If the argument
1350 @LI{all}is specified, the values of all of editor options are displayed.
1351 @sp 1
1352 Specifying an option name followed by the character
1353 @QT{?}
1354 causes the current value of that option to be displayed.
1356 @QT{?}
1357 can be separated from the option name by whitespace characters.
1359 @QT{?}
1360 is necessary only for Boolean valued options.
1361 Boolean options can be given values by the form
1362 @QT{set option}
1363 to turn them on, or
1364 @QT{set nooption}
1365 to turn them off.
1366 String and numeric options can be assigned by the form
1367 @QT{set option=value}.
1368 Any whitespace characters in strings can be included literally by preceding
1369 each with a backslash.
1370 More than one option can be set or listed by a single set command,
1371 by specifying multiple arguments, each separated from the next by
1372 whitespace characters.
1373 @table @asis
1374 @item Line:
1375 Unchanged.
1376 @item Options:
1377 None.
1378 @end table
1379 @end deftypefn
1380 @cindex shell
1381 @deftypefn Command {} {sh[ell]}
1383 Run the shell program.
1384 The program named by the
1385 @OP{shell}
1386 option is run with a
1387 @strong{-i}
1388 (for interactive) flag.
1389 Editing is resumed when that program exits.
1390 @table @asis
1391 @item Line:
1392 Unchanged.
1393 @item Options:
1394 Affected by the
1395 @OP{shell}
1396 option.
1397 @end table
1398 @end deftypefn
1399 @cindex source
1400 @deftypefn Command {} {so[urce]} {file}
1402 Read and execute
1403 @CO{ex}
1404 commands from a file.
1405 @CO{Source}
1406 commands may be nested.
1407 @table @asis
1408 @item Line:
1409 Unchanged.
1410 @item Options:
1411 None.
1412 @end table
1413 @end deftypefn
1414 @cindex substitute
1415 @deftypefn Command {[range]} {s[ubstitute]} {[/pattern/replace/] [options] [count] [flags]}
1417 @cindex &
1418 @deftypefnx Command  {[range]} {&} {[options] [count] [flags]}
1419 @cindex ~
1420 @deftypefnx Command  {[range]} {~} {[options] [count] [flags]}
1421 Make substitutions.
1422 Replace the first instance of
1423 @LI{pattern}with the string
1424 @LI{replace}on the specified line(s).
1425 If the
1426 @QT{/pattern/repl/}
1427 argument is not specified, the
1428 @QT{/pattern/repl/}
1429 from the previous
1430 @CO{substitute}
1431 command is used.
1432 Any character other than an alphabetic, numeric, <blank> or backslash
1433 character may be used as the delimiter.
1434 @sp 1
1436 @LI{options}includes the letter
1437 @QT{c}
1438 (confirm), you will be prompted for confirmation before each replacement
1439 is done.
1440 An affirmative response (in English, a
1441 @QT{y}
1442 character) causes the replacement to be made.
1443 A quit response (in English, a
1444 @QT{q}
1445 character) causes the
1446 @CO{substitute}
1447 command to be terminated.
1448 Any other response causes the replacement not to be made, and the
1449 @CO{substitute}
1450 command continues.
1452 @LI{options}includes the letter
1453 @QT{g}
1454 (global), all nonoverlapping instances of
1455 @LI{pattern}in the line are replaced.
1456 @sp 1
1458 @CO{&}
1459 version of the command is the same as not specifying a pattern
1460 or replacement string to the
1461 @CO{substitute}
1462 command, and the
1463 @QT{&}
1464 is replaced by the pattern and replacement information from the
1465 previous substitute command.
1466 @sp 1
1468 @CO{~}
1469 version of the command is the same as
1470 @CO{&}
1472 @CO{s},
1473 except that the search pattern used is the last RE used in
1474 @emph{any}
1475 command, not necessarily the one used in the last
1476 @CO{substitute}
1477 command.
1478 @sp 1
1479 For example, in the sequence
1480 @example
1481 s/red/blue/
1482 /green
1484 @end example
1486 @QT{~}
1487 is equivalent to
1488 @QT{s/green/blue/}.
1489 @sp 1
1491 @CO{substitute}
1492 command may be interrupted, using the terminal interrupt character.
1493 All substitutions completed before the interrupt are retained.
1494 @table @asis
1495 @item Line:
1496 Set to the last line upon which a substitution was made.
1497 @item Options:
1498 Affected by the
1499 @OP{ignorecase}
1501 @OP{magic}
1502 option.
1503 @end table
1504 @end deftypefn
1505 @cindex suspend
1506 @deftypefn Command {} {su[spend][!]}
1508 @cindex stop
1509 @deftypefnx Command {}  {st[op][!]}
1510 @deftypefnx Comamnd {}  <control-Z>
1511 Suspend the edit session.
1512 Appending a
1513 @QT{!}
1514 character to these commands turns off the
1515 @OP{autowrite}
1516 option for the command.
1517 @table @asis
1518 @item Line:
1519 Unchanged.
1520 @item Options:
1521 Affected by the
1522 @OP{autowrite}
1524 @OP{writeany}
1525 options.
1526 @end table
1527 @end deftypefn
1528 @cindex tag
1529 @deftypefn Command {} {ta[g][!]} {tagstring}
1531 Edit the file containing the specified tag.
1532 If the tag is in a different file, then the new file is edited.
1533 If the current file has been modified since the last complete write,
1535 @CO{tag}
1536 command will fail.
1537 This check can be overridden by appending the
1538 @QT{!}
1539 character to the command name.
1540 @sp 1
1542 @CO{tag}
1543 command searches for
1544 @LI{tagstring}in the tags file(s) specified by the
1545 @OP{tags}
1546 option.
1547 (See
1548 @XR{ctags,1}
1549 for more information on tags files.)
1550 @sp 1
1551 Capitalizing the first letter of the command, i.e.
1552 @CO{Tag},
1553 while in
1554 @CO{vi}
1555 mode, will edit the file in a new screen.
1556 In this case, any modifications to the current file are ignored.
1557 @table @asis
1558 @item Line:
1559 Set to the line indicated by the tag.
1560 @item Options:
1561 Affected by the
1562 @OP{autowrite},
1563 @OP{taglength},
1564 @OP{tags}
1566 @OP{writeany}
1567 options.
1568 @end table
1569 @end deftypefn
1570 @cindex tagnext
1571 @deftypefn Command {} {tagn[ext][!]}
1573 Edit the file containing the next context for the current tag.
1574 If the context is in a different file, then the new file is edited.
1575 If the current file has been modified since the last complete write,
1577 @CO{tagnext}
1578 command will fail.
1579 This check can be overridden by appending the
1580 @QT{!}
1581 character to the command name.
1582 @sp 1
1583 Capitalizing the first letter of the command, i.e.
1584 @CO{Tagnext},
1585 while in 
1586 @CO{vi}
1587 mode, will edit the file in a new screen.
1588 In this case, any modifications to the current file are ignored.
1589 @table @asis 
1590 @item Line:
1591 Set to the line indicated by the tag.
1592 @item Options:
1593 Affected by the 
1594 @OP{autowrite}
1596 @OP{writeany}
1597 options.
1598 @end table
1599 @end deftypefn
1600 @cindex tagpop
1601 @deftypefn Command {} {tagp[op][!]} {[file | number]}
1603 Pop to the specified tag in the tags stack.
1604 If neither
1605 @LI{file}or
1606 @LI{number}is specified, the
1607 @CO{tagpop}
1608 command pops to the most recent entry on the tags stack.
1610 @LI{file}or
1611 @LI{number}is specified, the
1612 @CO{tagpop}
1613 command pops to the most recent entry in the tags stack for that file,
1614 or numbered entry in the tags stack, respectively.
1615 (See the
1616 @CO{display}
1617 command for information on displaying the tags stack.)
1618 @sp 1
1619 If the file has been modified since the last complete write, the
1620 @CO{tagpop}
1621 command will fail.
1622 This check may be overridden by appending a
1623 @QT{!}
1624 character to the command name.
1625 @table @asis
1626 @item Line:
1627 Set to the line indicated by the tag.
1628 @item Options:
1629 Affected by the
1630 @OP{autowrite}
1632 @OP{writeany}
1633 options.
1634 @end table
1635 @end deftypefn
1636 @cindex tagprev
1637 @deftypefn Command {} {tagp[rev][!]}
1639 Edit the file containing the previous context for the current tag.
1640 If the context is in a different file, then the new file is edited.
1641 If the current file has been modified since the last complete write,
1643 @CO{tagprev}
1644 command will fail.
1645 This check can be overridden by appending the
1646 @QT{!}
1647 character to the command name.
1648 @sp 1
1649 Capitalizing the first letter of the command, i.e.
1650 @CO{Tagprev},
1651 while in 
1652 @CO{vi}
1653 mode, will edit the file in a new screen.
1654 In this case, any modifications to the current file are ignored.
1655 @table @asis 
1656 @item Line:
1657 Set to the line indicated by the tag.
1658 @item Options:
1659 Affected by the 
1660 @OP{autowrite}
1662 @OP{writeany}
1663 options.
1664 @end table
1665 @end deftypefn
1666 @cindex tagtop
1667 @deftypefn Command {} {tagt[op][!]}
1669 Pop to the least recent tag on the tags stack, clearing the tags stack.
1670 @sp 1
1671 If the file has been modified since the last complete write, the
1672 @CO{tagtop}
1673 command will fail.
1674 This check may be overridden by appending a
1675 @QT{!}
1676 character to the command name.
1677 @table @asis
1678 @item Line:
1679 Set to the line indicated by the tag.
1680 @item Options:
1681 Affected by the
1682 @OP{autowrite}
1684 @OP{writeany}
1685 options.
1686 @end table
1687 @end deftypefn
1688 @cindex unabbrev
1689 @deftypefn Command {} {una[bbrev]} {lhs}
1691 Delete an abbreviation.
1692 Delete
1693 @LI{lhs}from the current list of abbreviations.
1694 @table @asis
1695 @item Line:
1696 Unchanged.
1697 @item Options:
1698 None.
1699 @end table
1700 @end deftypefn
1701 @cindex undo
1702 @deftypefn Command {} {u[ndo]}
1704 Undo the last change made to the file.
1705 Changes made by
1706 @CO{global},
1707 @CO{v},
1708 @CO{visual}
1709 and map sequences are considered a single command.
1710 If repeated, the
1711 @CO{u}
1712 command alternates between these two states, and is its own inverse.
1713 @table @asis
1714 @item Line:
1715 Set to the last line modified by the command.
1716 @item Options:
1717 None.
1718 @end table
1719 @end deftypefn
1720 @cindex unmap
1721 @deftypefn Command {} {unm[ap][!]} {lhs}
1723 Unmap a mapped string.
1724 Delete the command mode map definition for
1725 @LI{lhs}.
1726 If a
1727 @QT{!}
1728 character is appended to the command name, delete the text input mode
1729 map definition instead.
1730 @table @asis
1731 @item Line:
1732 Unchanged.
1733 @item Options:
1734 None.
1735 @end table
1736 @end deftypefn
1737 @cindex version
1738 @deftypefn Command {} {ve[rsion]}
1740 Display the version of the
1741 @CO{ex/vi}
1742 editor.
1743 @end deftypefn
1744 @cindex visual
1745 @deftypefn Command {[line]} {vi[sual]} {[type] [count] [flags]}
1747 @CO{Ex}
1748 mode only.
1749 Enter
1750 @CO{vi}.
1752 @LI{type}is optional, and can be
1753 @QT{-},
1754 @QT{+}
1756 @QT{^},
1757 as in the
1758 @CO{ex}
1759 @CO{z}
1760 command, to specify the position of the specified line in the screen
1761 window.
1762 (The default is to place the line at the top of the screen window.)
1764 @LI{count}specifies the number of lines that will initially be displayed.
1765 (The default is the value of the
1766 @OP{window}
1767 editor option.)
1768 @table @asis
1769 @item Line:
1770 Unchanged unless
1771 @LI{line}is specified, in which case it is set to that line.
1772 @item Options:
1773 None.
1774 @end table
1775 @end deftypefn
1776 @cindex visual
1777 @deftypefn Command {} {vi[sual][!]} {[+cmd] [file]}
1779 @CO{Vi}
1780 mode only.
1781 Edit a new file.
1782 Identical to the
1783 @QT{edit[!] [+cmd] [file]}
1784 command.
1785 @sp 1
1786 Capitalizing the first letter of the command, i.e.
1787 @CO{Visual},
1788 will edit the file in a new screen.
1789 In this case, any modifications to the current file are ignored.
1790 @end deftypefn
1791 @cindex viusage
1792 @deftypefn Command {} {viu[sage]} {[command]}
1794 Display usage for a
1795 @CO{vi}
1796 command.
1798 @LI{command}is specified, a usage statement for that command is displayed.
1799 Otherwise, usage statements for all
1800 @CO{vi}
1801 commands are displayed.
1802 @table @asis
1803 @item Line:
1804 Unchanged.
1805 @item Options:
1806 None.
1807 @end table
1808 @end deftypefn
1809 @cindex write
1810 @deftypefn Command {[range]} {w[rite][!]} {[>>] [file]}
1812 @deftypefnx Command  {[range]} {w[rite]} {[!] [file]}
1813 @cindex wn
1814 @deftypefnx Command  {[range]} {wn[!]} {[>>] [file]}
1815 @cindex wq
1816 @deftypefnx Command  {[range]} {wq[!]} {[>>] [file]}
1817 Write the file.
1818 The specified lines (the entire file, if no range is given) is written
1820 @LI{file}.
1822 @LI{file}is not specified, the current pathname is used.
1824 @LI{file}is specified, and it exists, or if the current pathname was set using the
1825 @CO{file}
1826 command, and the file already exists, these commands will fail.
1827 Appending a
1828 @QT{!}
1829 character to the command name will override this check and the write
1830 will be attempted, regardless.
1831 @sp 1
1832 Specifying the optional
1833 @QT{>>}
1834 string will cause the write to be appended to the file, in which case
1835 no tests are made for the file already existing.
1836 @sp 1
1837 If the file is preceded by a
1838 @QT{!}
1839 character, the program named by the shell edit option is
1840 invoked with file as its second argument, and the specified
1841 lines are passed as standard input to that command.
1843 @QT{!}
1844 in this usage must be separated from command name by at least one
1845 whitespace character.
1846 The special meaning of the
1847 @QT{!}
1848 may be overridden by escaping it with a backslash
1849 @PQ{\e}
1850 character.
1851 @sp 1
1853 @CO{wq}
1854 version of the write command will exit the editor after writing the file,
1855 if there are no further files to edit.
1856 Appending a
1857 @QT{!}
1858 character to the command name or entering two
1859 @QQ{quit}
1860 commands (i.e.
1861 @CO{wq},
1862 @CO{quit},
1863 @CO{xit}
1865 @CO{ZZ})
1866 in a row) will override this check and the editor will exit,
1867 ignoring any files that have not yet been edited.
1868 @sp 1
1870 @CO{wn}
1871 version of the write command will move to the next file after writing
1872 the file, unless the write fails.
1873 @table @asis
1874 @item Line:
1875 Unchanged.
1876 @item Options:
1877 Affected by the
1878 @OP{readonly}
1880 @OP{writeany}
1881 options.
1882 @end table
1883 @end deftypefn
1884 @cindex xit
1885 @deftypefn Command {[range]} {x[it][!]} {[file]}
1887 Write the file if it has been modified.
1888 The specified lines are written to
1889 @LI{file},
1890 if the file has been modified since the last complete write to any
1891 file.
1892 If no
1893 @LI{range}is specified, the entire file is written.
1894 @sp 1
1896 @CO{xit}
1897 command will exit the editor after writing the file,
1898 if there are no further files to edit.
1899 Appending a
1900 @QT{!}
1901 character to the command name or entering two
1902 @QQ{quit}
1903 commands (i.e.
1904 @CO{wq},
1905 @CO{quit},
1906 @CO{xit}
1908 @CO{ZZ})
1909 in a row) will override this check and the editor will exit,
1910 ignoring any files that have not yet been edited.
1911 @table @asis
1912 @item Line:
1913 Unchanged.
1914 @item Options:
1915 Affected by the
1916 @OP{readonly}
1918 @OP{writeany}
1919 options.
1920 @end table
1921 @end deftypefn
1922 @cindex yank
1923 @deftypefn Command {[range]} {ya[nk]} {[buffer] [count]}
1925 Copy the specified lines to a buffer.
1926 If no buffer is specified, the unnamed buffer is used.
1927 @table @asis
1928 @item Line:
1929 Unchanged.
1930 @item Options:
1931 None.
1932 @end table
1933 @end deftypefn
1934 @cindex z
1935 @deftypefn Command {[line]} {z} {[type] [count] [flags]}
1937 Adjust the window.
1938 If no
1939 @LI{type}is specified, then
1940 @LI{count}lines following the specified line are displayed.
1941 The default
1942 @LI{count}is the value of the
1943 @OP{window}
1944 option.
1946 @LI{type}argument changes the position at which
1947 @LI{line}is displayed on the screen by changing the number of lines
1948 displayed before and after
1949 @LI{line}.
1950 The following
1951 @LI{type}characters may be used:
1952 @table @asis
1953 @item -
1954 Place the line at the bottom of the screen.
1955 @item +
1956 Place the line at the top of the screen.
1957 @item .
1958 Place the line in the middle of the screen.
1959 @item ^
1960 Write out count lines starting
1961 @LI{count * 2}lines before
1962 @LI{line};
1963 the net effect of this is that a
1964 @QT{z^}
1965 command following a
1966 @CO{z}
1967 command writes the previous page.
1968 @item =
1969 Center
1970 @LI{line}on the screen with a line of hyphens displayed immediately before and
1971 after it.
1972 The number of preceding and following lines of text displayed are
1973 reduced to account for those lines.
1974 @end table
1975 @table @asis
1976 @item Line:
1977 Set to the last line displayed, with the exception of the
1978 @QT{=}
1979 @LI{type},
1980 where the current line is set to the line specified by the command.
1981 @item Options:
1982 Affected by the
1983 @OP{scroll}
1984 option.
1985 @end table
1986 @end deftypefn