replace roff reference by texinfo version
[nvi.git] / docs / vi.ref / ex.cmd.texi
blobba9a93558a776f9792c73b8108c978e1ef0a59fd
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.1 2001/08/18 20:43:47 skimo Exp $ (Berkeley) $Date: 2001/08/18 20:43:47 $
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]}
668 @deftypefnx Command {}  {ex[!]} {[+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 @table @asis
696 @item Line:
697 If you have previously edited the file, the current line will be set
698 to your last position in the file.
699 If that position does not exist, or you have not previously edited the
700 file, the current line will be set to the first line of the file if
701 you are in
702 @CO{vi}
703 mode, and the last line of the file if you are in
704 @CO{ex}.
705 @item Options:
706 None.
707 @end table
708 @end deftypefn
709 @cindex exusage
710 @deftypefn Command {} {exu[sage]} {[command]}
712 Display usage for an
713 @CO{ex}
714 command.
716 @LI{command}is specified, a usage statement for that command is displayed.
717 Otherwise, usage statements for all
718 @CO{ex}
719 commands are displayed.
720 @table @asis
721 @item Line:
722 Unchanged.
723 @item Options:
724 None.
725 @end table
726 @end deftypefn
727 @cindex file
728 @deftypefn Command {} {f[ile]} {[file]}
730 Display and optionally change the file name.
731 If a file name is specified, the current pathname is changed to the
732 specified name.
733 The current pathname, the number of lines, and the current position
734 in the file are displayed.
735 @table @asis
736 @item Line:
737 Unchanged.
738 @item Options:
739 None.
740 @end table
741 @end deftypefn
742 @cindex fg
743 @deftypefn Command {} {fg} {[name]}
745 @CO{Vi}
746 mode only.
747 Foreground the specified screen.
748 If the argument name doesn't exactly match the name of a file displayed
749 by a background screen,
750 it is compared against the last component of each of the file names.
751 If no background screen is specified,
752 the first background screen is foregrounded.
753 @sp 1
754 By default,
755 foregrounding causes the current screen to be swapped with the backgrounded
756 screen.
757 Capitalizing the first letter of the command, i.e.
758 @CO{Fg},
759 will foreground the backgrounded screen in a new screen instead of
760 swapping it with the current screen.
761 @table @asis
762 @item Line:
763 Set to the current line when the screen was last edited.
764 @item Options:
765 None.
766 @end table
767 @end deftypefn
768 @cindex global
769 @deftypefn Command {[range]} {g[lobal]} {/pattern/ [commands]}
771 @cindex v
772 @deftypefnx Command  {[range]} {v} {/pattern/ [commands]}
773 Apply commands to lines matching (or not matching) a pattern.
774 The lines within the given range that match
775 @PQ{g[lobal]},
776 or do not match
777 @PQ{v}
778 the given pattern are selected.
779 Then, the specified
780 @CO{ex}
781 command(s) are executed with the current line
782 @PQ{.}
783 set to each selected line.
784 If no range is specified, the entire file is searched for matching,
785 or not matching, lines.
786 @sp 1
787 Multiple commands can be specified, one per line, by escaping each
788 @LI{<newline>}character with a backslash, or by separating commands with a
789 @QT{|}
790 character.
791 If no commands are specified, the command defaults to the
792 @CO{print}
793 command.
794 @sp 1
795 For the
796 @CO{append},
797 @CO{change}
799 @CO{insert}
800 commands, the input text must be part of the global command line.
801 In this case, the terminating period can be omitted if it ends the commands.
802 @sp 1
804 @CO{visual}
805 command may also be specified as one of the
806 @CO{ex}
807 commands.
808 In this mode, input is taken from the terminal.
809 Entering a
810 @CO{Q}
811 command in
812 @CO{vi}
813 mode causes the next line matching the pattern to be selected and
814 @CO{vi}
815 to be reentered, until the list is exhausted.
816 @sp 1
818 @CO{global},
819 @CO{v}
821 @CO{undo}
822 commands cannot be used as part of these commands.
823 @sp 1
824 The editor options
825 @OP{autoindent},
826 @OP{autoprint}
828 @OP{report}
829 are turned off for the duration of the
830 @CO{global}
832 @CO{v}
833 commands.
834 @table @asis
835 @item Line:
836 The last line modified.
837 @item Options:
838 Affected by the
839 @OP{ignorecase}
841 @OP{magic}
842 options.
843 Turns off the
844 @OP{autoindent},
845 @OP{autoprint}
847 @OP{report}
848 options.
849 @end table
850 @end deftypefn
851 @cindex help
852 @deftypefn Command {} {he[lp]}
854 Display a help message.
855 @table @asis
856 @item Line:
857 Unchanged.
858 @item Options:
859 None.
860 @end table
861 @end deftypefn
862 @cindex insert
863 @deftypefn Command {[line]} {i[nsert][!]}
865 The input text is inserted before the specified line.
866 Following the command name with a
867 @QT{!}
868 character causes the
869 @OP{autoindent}
870 option setting to be toggled for the duration of this command.
871 @table @asis
872 @item Line:
873 Set to the last line input; if no lines were input,
874 set to the line before the target line, or to the first line
875 of the file if there are no lines preceding the target line.
876 Affected by the
877 @OP{autoindent}
879 @OP{number}
880 options.
881 @end table
882 @end deftypefn
883 @cindex join
884 @deftypefn Command {[range]} {j[oin][!]} {[count] [flags]}
886 Join lines of text together.
887 @sp 1
889 @LI{count}specified to the
890 @CO{join}
891 command specifies that the last line of the
892 @LI{range}plus
893 @LI{count}subsequent lines will be joined.
894 (Note, this differs by one from the general rule where only
895 @LI{count}- 1
896 subsequent lines are affected.)
897 @sp 1
898 If the current line ends with a whitespace character, all whitespace
899 is stripped from the next line.
900 Otherwise, if the next line starts with a open parenthesis
901 @PQ{(},
902 do nothing.
903 Otherwise, if the current line ends with a question mark
904 @PQ{?},
905 period
906 @PQ{.}
907 or exclamation point
908 @PQ{!},
909 insert two spaces.
910 Otherwise, insert a single space.
911 @sp 1
912 Appending a
913 @QT{!}
914 character to the command name causes a simpler join with no
915 white-space processing.
916 @table @asis
917 @item Line:
918 Unchanged.
919 @item Options:
920 None.
921 @end table
922 @end deftypefn
923 @cindex list
924 @deftypefn Command {[range]} {l[ist]} {[count] [flags]}
926 Display the lines unambiguously.
927 Tabs are displayed as
928 @QT{^I},
929 and the end of the line is marked with a
930 @QT{$}
931 character.
932 @table @asis
933 @item Line:
934 Set to the last line displayed.
935 @item Options:
936 Affected by the
937 @OP{number}
938 option.
939 @end table
940 @end deftypefn
941 @cindex map
942 @deftypefn Command {} {map[!]} {[lhs rhs]}
944 Define or display maps (for
945 @CO{vi}
946 only).
947 @sp 1
949 @QT{lhs}
951 @QT{rhs}
952 are not specified, the current set of command mode maps are displayed.
953 If a
954 @QT{!}
955 character is appended to to the command,
956 the text input mode maps are displayed.
957 @sp 1
958 Otherwise, when the
959 @QT{lhs}
960 character sequence is entered in
961 @CO{vi},
962 the action is as if the corresponding
963 @QT{rhs}
964 had been entered.
965 If a
966 @QT{!}
967 character is appended to the command name,
968 the mapping is effective during text input mode,
969 otherwise, it is effective during command mode.
970 This allows
971 @QT{lhs}
972 to have two different macro definitions at the same time: one for command
973 mode and one for input mode.
974 @sp 1
975 Whitespace characters require escaping with a
976 @LI{<literal-next>}character to be entered in the
977 @LI{lhs}string in visual mode.
978 @sp 1
979 Normally, keys in the
980 @LI{rhs}string are remapped (see the
981 @OP{remap}
982 option),
983 and it is possible to create infinite loops.
984 However, keys which map to themselves are not further remapped,
985 regardless of the setting of the
986 @OP{remap}
987 option.
988 For example, the command
989 @QT{:map n nz.}
990 maps the
991 @QT{n}
992 key to the
993 @CO{n}
995 @CO{z}
996 commands.
997 @sp 1
998 To exit an infinitely looping map, use the terminal
999 @LI{<interrupt>}character.
1000 @table @asis
1001 @item Line:
1002 Unchanged.
1003 @item Options:
1004 Affected by the
1005 @OP{remap}
1006 option.
1007 @end table
1008 @cindex mark
1009 @end deftypefn
1010 @cindex k
1011 @deftypefn Command {[line]} {ma[rk]} {<character>}
1013 @deftypefnx Command  {[line]} {k} {<character>}
1014 Mark the line with the mark
1015 @LI{<character>}.
1016 The expressions
1017 @QT{'<character>}
1019 @QT{`<character>}
1020 can then be used as an address in any command that uses one.
1021 @table @asis
1022 @item Line:
1023 Unchanged.
1024 @item Options:
1025 None.
1026 @end table
1027 @end deftypefn
1028 @cindex move
1029 @deftypefn Command {[range]} {m[ove]} {line}
1031 Move the specified lines after the target line.
1032 A target line of 0 places the lines at the beginning of the file.
1033 @table @asis
1034 @item Line:
1035 Set to the first of the moved lines.
1036 @item Options:
1037 None.
1038 @end table
1039 @end deftypefn
1040 @cindex mkexrc
1041 @deftypefn Command {} {mk[exrc][!]} {file}
1043 Write the abbreviations, editor options and maps to the specified
1044 file.
1045 Information is written in a form which can later be read back in
1046 using the
1047 @CO{ex}
1048 @CO{source}
1049 command.
1051 @LI{file}already exists, the
1052 @CO{mkexrc}
1053 command will fail.
1054 This check can be overridden by appending a
1055 @QT{!}
1056 character to the command.
1057 @table @asis
1058 @item Line:
1059 Unchanged.
1060 @item Options:
1061 None.
1062 @end table
1063 @end deftypefn
1064 @cindex next
1065 @deftypefn Command {} {n[ext][!]} {[file ...]}
1067 Edit the next file from the argument list.
1069 @CO{next}
1070 command will fail if the file has been modified since the last complete
1071 write.
1072 This check can be overridden by appending the
1073 @QT{!}
1074 character to the command name.
1075 The argument list can optionally be replaced by specifying a new one
1076 as arguments to this command.
1077 In this case, editing starts with the first file on the new list.
1078 @sp 1
1079 Capitalizing the first letter of the command, i.e.
1080 @CO{Next},
1081 while in
1082 @CO{vi}
1083 mode, will set the argument list and edit the file in a new screen.
1084 In this case, any modifications to the current file are ignored.
1085 @table @asis
1086 @item Line:
1087 Set as described for the
1088 @CO{edit}
1089 command.
1090 @item Options:
1091 Affected by the options
1092 @OP{autowrite}
1094 @OP{writeany}.
1095 @end table
1096 @end deftypefn
1097 @cindex open
1098 @deftypefn Command {[line]} {o[pen]} {/pattern/ [flags]}
1100 Enter open mode.
1101 Open mode is the same as being in
1102 @CO{vi},
1103 but with a one-line window.
1104 All the standard
1105 @CO{vi}
1106 commands are available.
1107 If a match is found for the optional RE argument,
1108 the cursor is set to the start of the matching pattern.
1109 @sp 1
1110 @emph{This command is not yet implemented.}
1111 @table @asis
1112 @item Line:
1113 Unchanged, unless the optional RE is specified, in which case it is
1114 set to the line where the matching pattern is found.
1115 @item Options:
1116 Affected by the
1117 @OP{open}
1118 option.
1119 @end table
1120 @end deftypefn
1121 @cindex preserve
1122 @deftypefn Command {} {pre[serve]}
1124 Save the file in a form that can later be recovered using the
1125 @CO{ex}
1126 @strong{-r}
1127 option.
1128 When the file is preserved, an email message is sent to the user.
1129 @table @asis
1130 @item Line:
1131 Unchanged.
1132 @item Options:
1133 None.
1134 @end table
1135 @end deftypefn
1136 @cindex previous
1137 @deftypefn Command {} {prev[ious][!]}
1139 Edit the previous file from the argument list.
1141 @CO{previous}
1142 command will fail if the file has been modified since the last complete
1143 write.
1144 This check can be overridden by appending the
1145 @QT{!}
1146 character to the command name.
1147 @sp 1
1148 Capitalizing the first letter of the command, i.e.
1149 @CO{Previous},
1150 while in
1151 @CO{vi}
1152 mode, will edit the file in a new screen.
1153 In this case, any modifications to the current file are ignored.
1154 @table @asis
1155 @item Line:
1156 Set as described for the
1157 @CO{edit}
1158 command.
1159 @item Options:
1160 Affected by the options
1161 @OP{autowrite}
1163 @OP{writeany}.
1164 None.
1165 @end table
1166 @end deftypefn
1167 @cindex print
1168 @deftypefn Command {[range]} {p[rint]} {[count] [flags]}
1170 Display the specified lines.
1171 @table @asis
1172 @item Line:
1173 Set to the last line displayed.
1174 @item Options:
1175 Affected by the
1176 @OP{list}
1178 @OP{number}
1179 option.
1180 @end table
1181 @end deftypefn
1182 @cindex put
1183 @deftypefn Command {[line]} {pu[t]} {[buffer]}
1185 Append buffer contents to the current line.
1186 If a buffer is specified, its contents are appended to the line,
1187 otherwise, the contents of the unnamed buffer are used.
1188 @table @asis
1189 @item Line:
1190 Set to the line after the current line.
1191 @item Options:
1192 None.
1193 @end table
1194 @end deftypefn
1195 @cindex quit
1196 @deftypefn Command {} {q[uit][!]}
1198 End the editing session.
1199 If the file has been modified since the last complete write, the
1200 @CO{quit}
1201 command will fail.
1202 This check may be overridden by appending a
1203 @QT{!}
1204 character to the command.
1205 @sp 1
1206 If there are more files to edit, the
1207 @CO{quit}
1208 command will fail.
1209 Appending a
1210 @QT{!}
1211 character to the command name or entering two
1212 @CO{quit}
1213 commands (i.e.
1214 @CO{wq},
1215 @CO{quit},
1216 @CO{xit}
1218 @CO{ZZ})
1219 in a row) will override this check and the editor will exit.
1220 @table @asis
1221 @item Line:
1222 Unchanged.
1223 @item Options:
1224 None.
1225 @end table
1226 @end deftypefn
1227 @cindex read
1228 @deftypefn Command {[line]} {r[ead][!]} {[file]}
1230 Read a file.
1231 A copy of the specified file is appended to the line.
1233 @LI{line}is 0, the copy is inserted at the beginning of the file.
1234 If no file is specified, the current file is read; if there is no
1235 current file, then
1236 @LI{file}becomes the current file.
1237 If there is no current file and no
1238 @LI{file}is specified, then the
1239 @CO{read}
1240 command will fail.
1241 @sp 1
1243 @LI{file}is preceded by a
1244 @QT{!}
1245 character,
1246 @LI{file}is treated as if it were a shell command, and passed to the program
1247 named by the
1248 @OP{shell}
1249 edit option.
1250 The standard and standard error outputs of that command are read into
1251 the file after the specified line.
1252 The special meaning of the
1253 @QT{!}
1254 character can be overridden by escaping it with a backslash
1255 @PQ{\e}
1256 character.
1257 @table @asis
1258 @item Line:
1259 When executed from
1260 @CO{ex},
1261 the current line is set to the last line read.
1262 When executed from
1263 @CO{vi},
1264 the current line is set to the first line read.
1265 @item Options:
1266 None.
1267 @end table
1268 @end deftypefn
1269 @cindex recover
1270 @deftypefn Command {} {rec[over]} {file}
1272 Recover
1273 @LI{file}if it was previously saved.
1274 If no saved file by that name exists, the
1275 @CO{recover}
1276 command behaves equivalently to the
1277 @CO{edit}
1278 command.
1279 @table @asis
1280 @item Line:
1281 Set as described for the
1282 @CO{edit}
1283 command.
1284 @item Options:
1285 None.
1286 @end table
1287 @end deftypefn
1288 @cindex resize
1289 @deftypefn Command {} {res[ize]} {[+|-]size}
1291 @CO{Vi}
1292 mode only.
1293 Grow or shrink the current screen.
1295 @LI{size}is a positive, signed number, the current screen is grown by that many lines.
1297 @LI{size}is a negative, signed number, the current screen is shrunk by that many lines.
1299 @LI{size}is not signed, the current screen is set to the specified
1300 @LI{size}.
1301 Applicable only to split screens.
1302 @table @asis
1303 @item Line:
1304 Unchanged.
1305 @item Options:
1306 None.
1307 @end table
1308 @end deftypefn
1309 @cindex rewind
1310 @deftypefn Command {} {rew[ind][!]}
1312 Rewind the argument list.
1313 If the current file has been modified since the last complete write,
1315 @CO{rewind}
1316 command will fail.
1317 This check may be overridden by appending the
1318 @QT{!}
1319 character to the command.
1320 @sp 1
1321 Otherwise, the current file is set to the first file in the argument
1322 list.
1323 @table @asis
1324 @item Line:
1325 Set as described for the
1326 @CO{edit}
1327 command.
1328 @item Options:
1329 Affected by the
1330 @OP{autowrite}
1332 @OP{writeany}
1333 options.
1334 @end table
1335 @end deftypefn
1336 @cindex set
1337 @deftypefn Command {} {se[t]} {[option[=[value]] ...] [nooption ...] [option? ...] [all]}
1339 Display or set editor options.
1340 When no arguments are specified, the editor option
1341 @OP{term},
1342 and any editor options whose values have been changed from the
1343 default settings are displayed.
1344 If the argument
1345 @LI{all}is specified, the values of all of editor options are displayed.
1346 @sp 1
1347 Specifying an option name followed by the character
1348 @QT{?}
1349 causes the current value of that option to be displayed.
1351 @QT{?}
1352 can be separated from the option name by whitespace characters.
1354 @QT{?}
1355 is necessary only for Boolean valued options.
1356 Boolean options can be given values by the form
1357 @QT{set option}
1358 to turn them on, or
1359 @QT{set nooption}
1360 to turn them off.
1361 String and numeric options can be assigned by the form
1362 @QT{set option=value}.
1363 Any whitespace characters in strings can be included literally by preceding
1364 each with a backslash.
1365 More than one option can be set or listed by a single set command,
1366 by specifying multiple arguments, each separated from the next by
1367 whitespace characters.
1368 @table @asis
1369 @item Line:
1370 Unchanged.
1371 @item Options:
1372 None.
1373 @end table
1374 @end deftypefn
1375 @cindex shell
1376 @deftypefn Command {} {sh[ell]}
1378 Run the shell program.
1379 The program named by the
1380 @OP{shell}
1381 option is run with a
1382 @strong{-i}
1383 (for interactive) flag.
1384 Editing is resumed when that program exits.
1385 @table @asis
1386 @item Line:
1387 Unchanged.
1388 @item Options:
1389 Affected by the
1390 @OP{shell}
1391 option.
1392 @end table
1393 @end deftypefn
1394 @cindex source
1395 @deftypefn Command {} {so[urce]} {file}
1397 Read and execute
1398 @CO{ex}
1399 commands from a file.
1400 @CO{Source}
1401 commands may be nested.
1402 @table @asis
1403 @item Line:
1404 Unchanged.
1405 @item Options:
1406 None.
1407 @end table
1408 @end deftypefn
1409 @cindex substitute
1410 @deftypefn Command {[range]} {s[ubstitute]} {[/pattern/replace/] [options] [count] [flags]}
1412 @cindex &
1413 @deftypefnx Command  {[range]} {&} {[options] [count] [flags]}
1414 @cindex ~
1415 @deftypefnx Command  {[range]} {~} {[options] [count] [flags]}
1416 Make substitutions.
1417 Replace the first instance of
1418 @LI{pattern}with the string
1419 @LI{replace}on the specified line(s).
1420 If the
1421 @QT{/pattern/repl/}
1422 argument is not specified, the
1423 @QT{/pattern/repl/}
1424 from the previous
1425 @CO{substitute}
1426 command is used.
1427 Any character other than an alphabetic, numeric, <blank> or backslash
1428 character may be used as the delimiter.
1429 @sp 1
1431 @LI{options}includes the letter
1432 @QT{c}
1433 (confirm), you will be prompted for confirmation before each replacement
1434 is done.
1435 An affirmative response (in English, a
1436 @QT{y}
1437 character) causes the replacement to be made.
1438 A quit response (in English, a
1439 @QT{q}
1440 character) causes the
1441 @CO{substitute}
1442 command to be terminated.
1443 Any other response causes the replacement not to be made, and the
1444 @CO{substitute}
1445 command continues.
1447 @LI{options}includes the letter
1448 @QT{g}
1449 (global), all nonoverlapping instances of
1450 @LI{pattern}in the line are replaced.
1451 @sp 1
1453 @CO{&}
1454 version of the command is the same as not specifying a pattern
1455 or replacement string to the
1456 @CO{substitute}
1457 command, and the
1458 @QT{&}
1459 is replaced by the pattern and replacement information from the
1460 previous substitute command.
1461 @sp 1
1463 @CO{~}
1464 version of the command is the same as
1465 @CO{&}
1467 @CO{s},
1468 except that the search pattern used is the last RE used in
1469 @emph{any}
1470 command, not necessarily the one used in the last
1471 @CO{substitute}
1472 command.
1473 @sp 1
1474 For example, in the sequence
1475 @example
1476 s/red/blue/
1477 /green
1479 @end example
1481 @QT{~}
1482 is equivalent to
1483 @QT{s/green/blue/}.
1484 @sp 1
1486 @CO{substitute}
1487 command may be interrupted, using the terminal interrupt character.
1488 All substitutions completed before the interrupt are retained.
1489 @table @asis
1490 @item Line:
1491 Set to the last line upon which a substitution was made.
1492 @item Options:
1493 Affected by the
1494 @OP{ignorecase}
1496 @OP{magic}
1497 option.
1498 @end table
1499 @end deftypefn
1500 @cindex suspend
1501 @deftypefn Command {} {su[spend][!]}
1503 @cindex stop
1504 @deftypefnx Command {}  {st[op][!]}
1505 @deftypefnx Comamnd {}  <control-Z>
1506 Suspend the edit session.
1507 Appending a
1508 @QT{!}
1509 character to these commands turns off the
1510 @OP{autowrite}
1511 option for the command.
1512 @table @asis
1513 @item Line:
1514 Unchanged.
1515 @item Options:
1516 Affected by the
1517 @OP{autowrite}
1519 @OP{writeany}
1520 options.
1521 @end table
1522 @end deftypefn
1523 @cindex tag
1524 @deftypefn Command {} {ta[g][!]} {tagstring}
1526 Edit the file containing the specified tag.
1527 If the tag is in a different file, then the new file is edited.
1528 If the current file has been modified since the last complete write,
1530 @CO{tag}
1531 command will fail.
1532 This check can be overridden by appending the
1533 @QT{!}
1534 character to the command name.
1535 @sp 1
1537 @CO{tag}
1538 command searches for
1539 @LI{tagstring}in the tags file(s) specified by the
1540 @OP{tags}
1541 option.
1542 (See
1543 @XR{ctags,1}
1544 for more information on tags files.)
1545 @sp 1
1546 Capitalizing the first letter of the command, i.e.
1547 @CO{Tag},
1548 while in
1549 @CO{vi}
1550 mode, will edit the file in a new screen.
1551 In this case, any modifications to the current file are ignored.
1552 @table @asis
1553 @item Line:
1554 Set to the line indicated by the tag.
1555 @item Options:
1556 Affected by the
1557 @OP{autowrite},
1558 @OP{taglength},
1559 @OP{tags}
1561 @OP{writeany}
1562 options.
1563 @end table
1564 @end deftypefn
1565 @cindex tagnext
1566 @deftypefn Command {} {tagn[ext][!]}
1568 Edit the file containing the next context for the current tag.
1569 If the context is in a different file, then the new file is edited.
1570 If the current file has been modified since the last complete write,
1572 @CO{tagnext}
1573 command will fail.
1574 This check can be overridden by appending the
1575 @QT{!}
1576 character to the command name.
1577 @sp 1
1578 Capitalizing the first letter of the command, i.e.
1579 @CO{Tagnext},
1580 while in 
1581 @CO{vi}
1582 mode, will edit the file in a new screen.
1583 In this case, any modifications to the current file are ignored.
1584 @table @asis 
1585 @item Line:
1586 Set to the line indicated by the tag.
1587 @item Options:
1588 Affected by the 
1589 @OP{autowrite}
1591 @OP{writeany}
1592 options.
1593 @end table
1594 @end deftypefn
1595 @cindex tagpop
1596 @deftypefn Command {} {tagp[op][!]} {[file | number]}
1598 Pop to the specified tag in the tags stack.
1599 If neither
1600 @LI{file}or
1601 @LI{number}is specified, the
1602 @CO{tagpop}
1603 command pops to the most recent entry on the tags stack.
1605 @LI{file}or
1606 @LI{number}is specified, the
1607 @CO{tagpop}
1608 command pops to the most recent entry in the tags stack for that file,
1609 or numbered entry in the tags stack, respectively.
1610 (See the
1611 @CO{display}
1612 command for information on displaying the tags stack.)
1613 @sp 1
1614 If the file has been modified since the last complete write, the
1615 @CO{tagpop}
1616 command will fail.
1617 This check may be overridden by appending a
1618 @QT{!}
1619 character to the command name.
1620 @table @asis
1621 @item Line:
1622 Set to the line indicated by the tag.
1623 @item Options:
1624 Affected by the
1625 @OP{autowrite}
1627 @OP{writeany}
1628 options.
1629 @end table
1630 @end deftypefn
1631 @cindex tagprev
1632 @deftypefn Command {} {tagp[rev][!]}
1634 Edit the file containing the previous context for the current tag.
1635 If the context is in a different file, then the new file is edited.
1636 If the current file has been modified since the last complete write,
1638 @CO{tagprev}
1639 command will fail.
1640 This check can be overridden by appending the
1641 @QT{!}
1642 character to the command name.
1643 @sp 1
1644 Capitalizing the first letter of the command, i.e.
1645 @CO{Tagprev},
1646 while in 
1647 @CO{vi}
1648 mode, will edit the file in a new screen.
1649 In this case, any modifications to the current file are ignored.
1650 @table @asis 
1651 @item Line:
1652 Set to the line indicated by the tag.
1653 @item Options:
1654 Affected by the 
1655 @OP{autowrite}
1657 @OP{writeany}
1658 options.
1659 @end table
1660 @end deftypefn
1661 @cindex tagtop
1662 @deftypefn Command {} {tagt[op][!]}
1664 Pop to the least recent tag on the tags stack, clearing the tags stack.
1665 @sp 1
1666 If the file has been modified since the last complete write, the
1667 @CO{tagtop}
1668 command will fail.
1669 This check may be overridden by appending a
1670 @QT{!}
1671 character to the command name.
1672 @table @asis
1673 @item Line:
1674 Set to the line indicated by the tag.
1675 @item Options:
1676 Affected by the
1677 @OP{autowrite}
1679 @OP{writeany}
1680 options.
1681 @end table
1682 @end deftypefn
1683 @cindex unabbrev
1684 @deftypefn Command {} {una[bbrev]} {lhs}
1686 Delete an abbreviation.
1687 Delete
1688 @LI{lhs}from the current list of abbreviations.
1689 @table @asis
1690 @item Line:
1691 Unchanged.
1692 @item Options:
1693 None.
1694 @end table
1695 @end deftypefn
1696 @cindex undo
1697 @deftypefn Command {} {u[ndo]}
1699 Undo the last change made to the file.
1700 Changes made by
1701 @CO{global},
1702 @CO{v},
1703 @CO{visual}
1704 and map sequences are considered a single command.
1705 If repeated, the
1706 @CO{u}
1707 command alternates between these two states, and is its own inverse.
1708 @table @asis
1709 @item Line:
1710 Set to the last line modified by the command.
1711 @item Options:
1712 None.
1713 @end table
1714 @end deftypefn
1715 @cindex unmap
1716 @deftypefn Command {} {unm[ap][!]} {lhs}
1718 Unmap a mapped string.
1719 Delete the command mode map definition for
1720 @LI{lhs}.
1721 If a
1722 @QT{!}
1723 character is appended to the command name, delete the text input mode
1724 map definition instead.
1725 @table @asis
1726 @item Line:
1727 Unchanged.
1728 @item Options:
1729 None.
1730 @end table
1731 @end deftypefn
1732 @cindex version
1733 @deftypefn Command {} {ve[rsion]}
1735 Display the version of the
1736 @CO{ex/vi}
1737 editor.
1738 @end deftypefn
1739 @cindex visual
1740 @deftypefn Command {[line]} {vi[sual]} {[type] [count] [flags]}
1742 @CO{Ex}
1743 mode only.
1744 Enter
1745 @CO{vi}.
1747 @LI{type}is optional, and can be
1748 @QT{-},
1749 @QT{+}
1751 @QT{^},
1752 as in the
1753 @CO{ex}
1754 @CO{z}
1755 command, to specify the position of the specified line in the screen
1756 window.
1757 (The default is to place the line at the top of the screen window.)
1759 @LI{count}specifies the number of lines that will initially be displayed.
1760 (The default is the value of the
1761 @OP{window}
1762 editor option.)
1763 @table @asis
1764 @item Line:
1765 Unchanged unless
1766 @LI{line}is specified, in which case it is set to that line.
1767 @item Options:
1768 None.
1769 @end table
1770 @end deftypefn
1771 @cindex visual
1772 @deftypefn Command {} {vi[sual][!]} {[+cmd] [file]}
1774 @CO{Vi}
1775 mode only.
1776 Edit a new file.
1777 Identical to the
1778 @QT{edit[!] [+cmd] [file]}
1779 command.
1780 @sp 1
1781 Capitalizing the first letter of the command, i.e.
1782 @CO{Visual},
1783 will edit the file in a new screen.
1784 In this case, any modifications to the current file are ignored.
1785 @end deftypefn
1786 @cindex viusage
1787 @deftypefn Command {} {viu[sage]} {[command]}
1789 Display usage for a
1790 @CO{vi}
1791 command.
1793 @LI{command}is specified, a usage statement for that command is displayed.
1794 Otherwise, usage statements for all
1795 @CO{vi}
1796 commands are displayed.
1797 @table @asis
1798 @item Line:
1799 Unchanged.
1800 @item Options:
1801 None.
1802 @end table
1803 @end deftypefn
1804 @cindex write
1805 @deftypefn Command {[range]} {w[rite][!]} {[>>] [file]}
1807 @deftypefnx Command  {[range]} {w[rite]} {[!] [file]}
1808 @cindex wn
1809 @deftypefnx Command  {[range]} {wn[!]} {[>>] [file]}
1810 @cindex wq
1811 @deftypefnx Command  {[range]} {wq[!]} {[>>] [file]}
1812 Write the file.
1813 The specified lines (the entire file, if no range is given) is written
1815 @LI{file}.
1817 @LI{file}is not specified, the current pathname is used.
1819 @LI{file}is specified, and it exists, or if the current pathname was set using the
1820 @CO{file}
1821 command, and the file already exists, these commands will fail.
1822 Appending a
1823 @QT{!}
1824 character to the command name will override this check and the write
1825 will be attempted, regardless.
1826 @sp 1
1827 Specifying the optional
1828 @QT{>>}
1829 string will cause the write to be appended to the file, in which case
1830 no tests are made for the file already existing.
1831 @sp 1
1832 If the file is preceded by a
1833 @QT{!}
1834 character, the program named by the shell edit option is
1835 invoked with file as its second argument, and the specified
1836 lines are passed as standard input to that command.
1838 @QT{!}
1839 in this usage must be separated from command name by at least one
1840 whitespace character.
1841 The special meaning of the
1842 @QT{!}
1843 may be overridden by escaping it with a backslash
1844 @PQ{\e}
1845 character.
1846 @sp 1
1848 @CO{wq}
1849 version of the write command will exit the editor after writing the file,
1850 if there are no further files to edit.
1851 Appending a
1852 @QT{!}
1853 character to the command name or entering two
1854 @QQ{quit}
1855 commands (i.e.
1856 @CO{wq},
1857 @CO{quit},
1858 @CO{xit}
1860 @CO{ZZ})
1861 in a row) will override this check and the editor will exit,
1862 ignoring any files that have not yet been edited.
1863 @sp 1
1865 @CO{wn}
1866 version of the write command will move to the next file after writing
1867 the file, unless the write fails.
1868 @table @asis
1869 @item Line:
1870 Unchanged.
1871 @item Options:
1872 Affected by the
1873 @OP{readonly}
1875 @OP{writeany}
1876 options.
1877 @end table
1878 @end deftypefn
1879 @cindex xit
1880 @deftypefn Command {[range]} {x[it][!]} {[file]}
1882 Write the file if it has been modified.
1883 The specified lines are written to
1884 @LI{file},
1885 if the file has been modified since the last complete write to any
1886 file.
1887 If no
1888 @LI{range}is specified, the entire file is written.
1889 @sp 1
1891 @CO{xit}
1892 command will exit the editor after writing the file,
1893 if there are no further files to edit.
1894 Appending a
1895 @QT{!}
1896 character to the command name or entering two
1897 @QQ{quit}
1898 commands (i.e.
1899 @CO{wq},
1900 @CO{quit},
1901 @CO{xit}
1903 @CO{ZZ})
1904 in a row) will override this check and the editor will exit,
1905 ignoring any files that have not yet been edited.
1906 @table @asis
1907 @item Line:
1908 Unchanged.
1909 @item Options:
1910 Affected by the
1911 @OP{readonly}
1913 @OP{writeany}
1914 options.
1915 @end table
1916 @end deftypefn
1917 @cindex yank
1918 @deftypefn Command {[range]} {ya[nk]} {[buffer] [count]}
1920 Copy the specified lines to a buffer.
1921 If no buffer is specified, the unnamed buffer is used.
1922 @table @asis
1923 @item Line:
1924 Unchanged.
1925 @item Options:
1926 None.
1927 @end table
1928 @end deftypefn
1929 @cindex z
1930 @deftypefn Command {[line]} {z} {[type] [count] [flags]}
1932 Adjust the window.
1933 If no
1934 @LI{type}is specified, then
1935 @LI{count}lines following the specified line are displayed.
1936 The default
1937 @LI{count}is the value of the
1938 @OP{window}
1939 option.
1941 @LI{type}argument changes the position at which
1942 @LI{line}is displayed on the screen by changing the number of lines
1943 displayed before and after
1944 @LI{line}.
1945 The following
1946 @LI{type}characters may be used:
1947 @table @asis
1948 @item -
1949 Place the line at the bottom of the screen.
1950 @item +
1951 Place the line at the top of the screen.
1952 @item .
1953 Place the line in the middle of the screen.
1954 @item ^
1955 Write out count lines starting
1956 @LI{count * 2}lines before
1957 @LI{line};
1958 the net effect of this is that a
1959 @QT{z^}
1960 command following a
1961 @CO{z}
1962 command writes the previous page.
1963 @item =
1964 Center
1965 @LI{line}on the screen with a line of hyphens displayed immediately before and
1966 after it.
1967 The number of preceding and following lines of text displayed are
1968 reduced to account for those lines.
1969 @end table
1970 @table @asis
1971 @item Line:
1972 Set to the last line displayed, with the exception of the
1973 @QT{=}
1974 @LI{type},
1975 where the current line is set to the line specified by the command.
1976 @item Options:
1977 Affected by the
1978 @OP{scroll}
1979 option.
1980 @end table
1981 @end deftypefn