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: vi.cmd.texi,v 8.1 2001/08/18 20:43:49 skimo Exp  (Berkeley) Date: 2001/08/18 20:43:49 
9@comment 
10@chapter Vi Description
11
12@CO{Vi} takes up the entire screen to display the edited file,
13except for the bottom line of the screen.
14The bottom line of the screen is used to enter
15@CO{exp}
16commands, and for
17@CO{vi}
18error and informational messages.
19If no other information is being displayed,
20the default display can show the current cursor row and cursor column,
21an indication of whether the file has been modified,
22and the current mode of the editor.
23See the
24@OP{ruler}
25and
26@OP{showmode}
27options for more information.
28
29Empty lines do not have any special representation on the screen,
30but lines on the screen that would logically come after the end of
31the file are displayed as a single tilde
32@PQ{~}
33character.
34To differentiate between empty lines and lines consisting of only
35whitespace characters, use the
36@OP{list}
37option.
38Historically, implementations of
39@CO{vi}
40have also displayed some lines as single asterisk
41@PQ{@@}
42characters.
43These were lines that were not correctly displayed, i.e. lines on the
44screen that did not correspond to lines in the file, or lines that did
45not fit on the current screen.
46@CO{Nvi}
47never displays lines in this fashion.
48
49@CO{Vi}
50is a modeful editor, i.e. it has two modes,
51@QQ{command}
52mode and
53@QQ{text input}
54mode.
55When
56@CO{vi}
57first starts, it is in command mode.
58There are several commands that change
59@CO{vi}
60into text input mode.
61The
62@LI{<escape>}character is used to resolve the text input into the file,
63and exit back into command mode.
64In
65@CO{vi}
66command mode, the cursor is always positioned on the last column of
67characters which take up more than one column on the screen.
68In
69@CO{vi}
70text insert mode, the cursor is positioned on the first column of
71characters which take up more than one column on the screen.
72
73When positioning the cursor to a new line and column,
74the type of movement is defined by the distance to the new cursor position.
75If the new position is close,
76the screen is scrolled to the new location.
77If the new position is far away,
78the screen is repainted so that the new position is on the screen.
79If the screen is scrolled,
80it is moved a minimal amount,
81and the cursor line will usually appear at the top or bottom of the screen.
82If the screen is repainted,
83the cursor line will appear in the center of the screen,
84unless the cursor is sufficiently close to the beginning or end of the file
85that this isn't possible.
86If the
87@OP{leftright}
88option is set, the screen may be scrolled or repainted in a horizontal
89direction as well as in a vertical one.
90
91A major difference between the historical
92@CO{vi}
93presentation and
94@CO{nvi}
95is in the scrolling and screen oriented position commands,
96@CO{<control-B>},
97@CO{<control-D>},
98@CO{<control-E>},
99@CO{<control-F>},
100@CO{<control-U>},
101@CO{<control-Y>},
102@CO{H},
103@CO{L}
104and
105@CO{M}.
106In historical implementations of
107@CO{vi},
108these commands acted on physical (as opposed to logical, or screen)
109lines.
110For lines that were sufficiently long in relation to the size of the
111screen, this meant that single line scroll commands might repaint the
112entire screen, scrolling or screen positioning commands might not change
113the screen or move the cursor at all, and some lines simply could not
114be displayed, even though
115@CO{vi}
116would edit the file that contained them.
117In
118@CO{nvi},
119these commands act on logical, i.e. screen lines.
120You are unlikely to notice any difference unless you are editing files
121with lines significantly longer than a screen width.
122
123@CO{Vi}
124keeps track of the currently
125@QQ{most attractive}
126cursor position.
127Each command description (for commands that alter the current cursor
128position),
129specifies if the cursor is set to a specific location in the line,
130or if it is moved to the
131@QQ{most attractive cursor position}.
132The latter means that the cursor is moved to the cursor position that
133is horizontally as close as possible to the current cursor position.
134If the current line is shorter than the cursor position
135@CO{vi}
136would select, the cursor is positioned on the last character in the line.
137(If the line is empty, the cursor is positioned on the first column
138of the line.)
139If a command moves the cursor to the most attractive position,
140it does not alter the current cursor position, and a subsequent
141movement will again attempt to move the cursor to that position.
142Therefore, although a movement to a line shorter than the currently
143most attractive position will cause the cursor to move to the end of
144that line, a subsequent movement to a longer line will cause the
145cursor to move back to the most attractive position.
146
147In addition, the
148@CO{$}
149command makes the end of each line the most attractive cursor position
150rather than a specific column.
151
152Each
153@CO{vi}
154command described below notes where the cursor ends up after it is
155executed.
156This position is described in terms of characters on the line, i.e.
157@QQ{the previous character},
158or,
159@QQ{the last character in the line}.
160This is to avoid needing to continually refer to on what part of the
161character the cursor rests.
162
163The following words have special meaning for
164@CO{vi}
165commands.
166@itemize @bullet
167@cindex "previous context"
168@IP{previous context}
169
170The position of the cursor before the command which caused the
171last absolute movement was executed.
172Each 
173@CO{vi}
174command described in the next section that is considered an
175absolute movement is so noted.
176In addition, specifying
177@emph{any}
178address to an
179@CO{ex}
180command is considered an absolute movement.
181@cindex "motion"
182@IP{motion}
183
184A second
185@CO{vi}
186command can be used as an optional trailing argument to the
187@CO{vi}
188@CO{<},
189@CO{>},
190@CO{!},
191@CO{c},
192@CO{d},
193@CO{y},
194and (depending on the
195@OP{tildeop}
196option)
197@CO{~}
198commands.
199This command indicates the end of the region of text that's affected by
200the command.
201The motion command may be either the command character repeated (in
202which case it means the current line) or a cursor movement command.
203In the latter case, the region affected by the command is from the
204starting or stopping cursor position which comes first in the file,
205to immediately before the starting or stopping cursor position which
206comes later in the file.
207Commands that operate on lines instead of using beginning and ending
208cursor positions operate on all of the lines that are wholly or
209partially in the region.
210In addition, some other commands become line oriented depending on
211where in the text they are used.
212The command descriptions below note these special cases.
213@sp 1
214The following commands may all be used as motion components for
215@CO{vi}
216commands:
217@sp 1
218@multitable {@CO{<control-N>}} {@CO{'<character>}} {@CO{<control-J>}} {@CO{<control-M>}}
219@item @CO{<control-A>} @tab @CO{<control-H>} @tab @CO{<control-J>} @tab @CO{<control-M>}
220@item @CO{<control-N>} @tab @CO{<control-P>} @tab @CO{<space>} @tab @CO{$}
221@item @CO{%} @tab @CO{'<character>} @tab @CO{(} @tab @CO{)}
222@item @CO{+} @tab @CO{,} @tab @CO{-} @tab @CO{/}
223@item @CO{0} @tab @CO{;} @tab @CO{?} @tab @CO{B}
224@item @CO{E} @tab @CO{F} @tab @CO{G} @tab @CO{H}
225@item @CO{L} @tab @CO{M} @tab @CO{N} @tab @CO{T}
226@item @CO{W} @tab @CO{[[} @tab @CO{]]} @tab @CO{^}
227@item @CO{_} @tab @CO{`<character>} @tab @CO{b} @tab @CO{e}
228@item @CO{f} @tab @CO{h} @tab @CO{j} @tab @CO{k}
229@item @CO{l} @tab @CO{n} @tab @CO{t} @tab @CO{w}
230@item @strong{@{} @tab @CO{|} @tab @strong{@}}
231@end multitable
232@sp 1
233The optional count prefix available for some of the
234@CO{vi}
235commands that take motion commands,
236or the count prefix available for the
237@CO{vi}
238commands that are used as motion components,
239may be included and is
240@emph{always}
241considered part of the motion argument.
242For example, the commands
243@QT{c2w}
244and
245@QT{2cw}
246are equivalent, and the region affected by the
247@CO{c}
248command is two words of text.
249In addition,
250if the optional count prefix is specified for both the
251@CO{vi}
252command and its motion component,
253the effect is multiplicative and is considered part of the motion argument.
254For example, the commands
255@QT{4cw}
256and
257@QT{2c2w}
258are equivalent, and the region affected by the
259@CO{c}
260command is four words of text.
261@cindex "count"
262@IP{count}
263
264A positive number used as an optional argument to most commands,
265either to give a size or a position (for display or movement commands),
266or as a repeat count (for commands that modify text).
267The count argument is always optional and defaults to 1 unless otherwise
268noted in the command description.
269@sp 1
270When a
271@CO{vi}
272command synopsis shows both a
273@LI{[buffer]}and
274@LI{[count]},
275they may be presented in any order.
276@cindex word
277@IP{word}
278
279Generally, in languages where it is applicable,
280@CO{vi}
281recognizes two kinds of words.
282First, a sequence of letters, digits and underscores,
283delimited at both ends by:
284characters other than letters, digits, or underscores,
285the beginning or end of a line, and the beginning or end of the file.
286Second, a sequence of characters other than letters, digits, underscores,
287or whitespace characters, delimited at both ends by: a letter, digit,
288underscore, or whitespace character,
289the beginning or end of a line, and the beginning or end of the file.
290For example, the characters
291@QT{ !@@#abc$%^ }
292contain three words:
293@QT{!@@#},
294@QT{abc}
295and
296@QT{$%^}.
297@sp 1
298Groups of empty lines (or lines containing only whitespace characters)
299are treated as a single word.
300@cindex "bigword"
301@IP{bigword}
302
303A set of non-whitespace characters preceded and followed by whitespace
304characters or the beginning or end of the file or line.
305For example, the characters
306@QT{ !@@#abc$%^ }
307contain one bigword:
308@QT{!@@#abc$%^}.
309@sp 1
310Groups of empty lines (or lines containing only whitespace characters)
311are treated as a single bigword.
312@cindex "paragraph"
313@IP{paragraph}
314
315An area of text that begins with either the beginning of a file,
316an empty line, or a section boundary, and continues until either
317an empty line, section boundary, or the end of the file.
318@sp 1
319Groups of empty lines (or lines containing only whitespace characters)
320are treated as a single paragraph.
321@sp 1
322Additional paragraph boundaries can be defined using the
323@OP{paragraphs}
324option.
325@cindex "section"
326@IP{section}
327
328An area of text that starts with the beginning of the file or a line
329whose first character is an open brace
330@comment PQ
331``@code{@{}''
332and continues until the next section or the end of the file.
333@sp 1
334Additional section boundaries can be defined using the
335@OP{sections}
336option.
337@cindex "sentence"
338@IP{sentence}
339
340An area of text that begins with either the beginning of the file or the
341first nonblank character following the previous sentence, paragraph, or
342section boundary and continues until the end of the file or a period
343@PQ{.}
344exclamation point
345@PQ{!}
346or question mark
347@PQ{?}
348character,
349followed by either an end-of-line or two whitespace characters.
350Any number of closing parentheses
351@PQ{)},
352brackets
353@PQ{]},
354double-quote
355@PQ{"}
356or single quote
357@PQ{'}
358characters can appear between the period, exclamation point,
359or question mark and the whitespace characters or end-of-line.
360@sp 1
361Groups of empty lines (or lines containing only whitespace characters)
362are treated as a single sentence.
363@chapter Vi Commands
364@end itemize
365
366The following section describes the commands available in the command
367mode of the
368@CO{vi}
369editor.
370In each entry below, the tag line is a usage synopsis for the command
371character.
372In addition, the final line and column the cursor rests upon,
373and any options which affect the command are noted.
374
375@cindex <control-A>
376@deftypefn Command {[count]} {<control-A>}
377
378Search forward
379@LI{count}times for the current word.
380The current word begins at the first non-whitespace character on or
381after the current cursor position,
382and extends up to the next non-word character or the end of the line.
383The search is literal, i.e. no characters in the word have any special
384meaning in terms of Regular Expressions.
385It is an error if no matching pattern is found between the starting position
386and the end of the file.
387@sp 1
388The
389@CO{<control-A>}
390command is an absolute movement.
391The
392@CO{<control-A>}
393command may be used as the motion component of other
394@CO{vi}
395commands, in which case any text copied into a buffer is
396character oriented.
397@table @asis
398@item Line:
399Set to the line where the word is found.
400@item Column:
401Set to the first character of the word.
402@item Options:
403Affected by the
404@OP{ignorecase}
405and
406@OP{wrapscan}
407options.
408@end table
409@end deftypefn
410@cindex <control-B>
411@deftypefn Command {[count]} {<control-B>}
412
413Page backward
414@LI{count}screens.
415Two lines of overlap are maintained, if possible,
416by displaying the window starting at line
417@LI{(top_line - count * window_size) + 2},
418where
419@LI{window_size}is the value of the
420@OP{window}
421option.
422(In the case of split screens, this size is corrected to the
423current screen size.)
424It is an error if the movement is past the beginning of the file.
425@table @asis
426@item Line:
427Set to the last line of text displayed on the screen.
428@item Column:
429Set to the first nonblank character of the line.
430@item Options:
431Affected by the
432@OP{window}
433option.
434@end table
435@end deftypefn
436@cindex <control-D>
437@deftypefn Command {[count]} {<control-D>}
438
439Scroll forward
440@LI{count}lines.
441If
442@LI{count}is not specified, scroll forward the number of lines specified by the last
443@CO{<control-D>}
444or
445@CO{<control-U>}
446command.
447If this is the first
448@CO{<control-D>}
449or
450@CO{<control-U>}
451command,
452scroll forward half the number of lines in the screen.
453(In the case of split screens, the default scrolling distance is
454corrected to half the current screen size.)
455It is an error if the movement is past the end of the file.
456@table @asis
457@item Line:
458Set to the current line plus the number of lines scrolled.
459@item Column:
460Set to the first nonblank character of the line.
461@item Options:
462None.
463@end table
464@end deftypefn
465@cindex <control-E>
466@deftypefn Command {[count]} {<control-E>}
467
468Scroll forward
469@LI{count}lines, leaving the cursor on the current line and column, if possible.
470It is an error if the movement is past the end of the file.
471@table @asis
472@item Line:
473Unchanged unless the current line scrolls off the screen,
474in which case it is set to the first line on the screen.
475@item Column:
476Unchanged unless the current line scrolls off the screen,
477in which case it is set to the most attractive cursor position.
478@item Options:
479None.
480@end table
481@end deftypefn
482@cindex <control-F>
483@deftypefn Command {[count]} {<control-F>}
484
485Page forward
486@LI{count}screens.
487Two lines of overlap are maintained, if possible,
488by displaying the window starting at line
489@LI{top_line + count * window_size - 2},
490where
491@LI{window_size}is the value of the
492@OP{window}
493option.
494(In the case of split screens, this size is corrected to the
495current screen size.)
496It is an error if the movement is past the end of the file.
497@table @asis
498@item Line:
499Set to the first line on the screen.
500@item Column:
501Set to the first nonblank character of the current line.
502@item Options:
503Affected by the
504@OP{window}
505option.
506@end table
507@end deftypefn
508@cindex <control-G>
509@deftypefn Command {} {<control-G>}
510
511Display the file information.
512The information includes the current pathname, the current line,
513the number of total lines in the file, the current line as a percentage
514of the total lines in the file, if the file has been modified,
515was able to be locked, if the file's name has been changed,
516and if the edit session is read-only.
517@table @asis
518@item Line:
519Unchanged.
520@item Column:
521Unchanged.
522@item Options:
523None.
524@end table
525@end deftypefn
526
527@cindex <control-H>
528@deftypefn Command {[count]} {<control-H>}
529@deftypefnx Command {[count]} {h}
530Move the cursor back
531@LI{count}characters in the current line.
532It is an error if the cursor is on the first character in the line.
533@sp 1
534The
535@CO{<control-H>}
536and
537@CO{h}
538commands may be used as the motion component of other
539@CO{vi}
540commands,
541in which case any text copied into a buffer is character oriented.
542@table @asis
543@item Line:
544Unchanged.
545@item Column:
546Set to the
547@LI{current - count}character, or, the first character in the line if
548@LI{count}is greater than or equal to the number of characters in the line
549before the cursor.
550@item Options:
551None.
552@end table
553@end deftypefn
554
555@cindex <control-J>
556@deftypefn Command {[count]} {<control-J>}
557
558@cindex <control-N>
559@deftypefnx Command  {[count]} {<control-N>}
560@cindex j
561@deftypefnx Command  {[count]} {j}
562Move the cursor down
563@LI{count}lines without changing the current column.
564It is an error if the movement is past the end of the file.
565@sp 1
566The
567@CO{<control-J>},
568@CO{<control-N>}
569and
570@CO{j}
571commands may be used as the motion component of other
572@CO{vi}
573commands, in which case any text copied into a buffer is
574line oriented.
575@table @asis
576@item Line:
577Set to the current line plus
578@LI{count}.
579@item Column:
580The most attractive cursor position.
581@item Options:
582None.
583@end table
584@end deftypefn
585@cindex <control-L>
586@deftypefn Command {} {<control-L>}
587
588@cindex <control-R>
589@deftypefnx Command {}  {<control-R>}
590Repaint the screen.
591@table @asis
592@item Line:
593Unchanged.
594@item Column:
595Unchanged.
596@item Options:
597None.
598@end table
599@end deftypefn
600@cindex <control-M>
601@deftypefn Command {[count]} {<control-M>}
602
603@cindex +
604@deftypefnx Command  {[count]} {+}
605Move the cursor down
606@LI{count}lines to the first nonblank character of that line.
607It is an error if the movement is past the end of the file.
608@sp 1
609The
610@CO{<control-M>}
611and
612@CO{+}
613commands may be used as the motion component of other
614@CO{vi}
615commands, in which case any text copied into a buffer is
616line oriented.
617@table @asis
618@item Line:
619Set to the current line plus
620@LI{count}.
621@item Column:
622Set to the first nonblank character in the line.
623@item Options:
624None.
625@end table
626@end deftypefn
627@cindex <control-P>
628@deftypefn Command {[count]} {<control-P>}
629
630@cindex k
631@deftypefnx Command  {[count]} {k}
632Move the cursor up
633@LI{count}lines, without changing the current column.
634It is an error if the movement is past the beginning of the file.
635@sp 1
636The
637@CO{<control-P>}
638and
639@CO{k}
640commands may be used as the motion component of other
641@CO{vi}
642commands, in which case any text copied into a buffer is
643line oriented.
644@table @asis
645@item Line:
646Set to the current line minus
647@LI{count}.
648@item Column:
649The most attractive cursor position.
650@item Options:
651None.
652@end table
653@end deftypefn
654@cindex <control-T>
655@deftypefn Command {} {<control-T>}
656
657Return to the most recent tag context.
658The
659@CO{<control-T>}
660command is an absolute movement.
661@table @asis
662@item Line:
663Set to the context of the previous tag command.
664@item Column:
665Set to the context of the previous tag command.
666@item Options:
667None.
668@end table
669@end deftypefn
670@cindex <control-U>
671@deftypefn Command {[count]} {<control-U>}
672
673Scroll backward
674@LI{count}lines.
675If
676@LI{count}is not specified, scroll backward the number of lines specified by the
677last
678@CO{<control-D>}
679or
680@CO{<control-U>}
681command.
682If this is the first
683@CO{<control-D>}
684or
685@CO{<control-U>}
686command,
687scroll backward half the number of lines in the screen.
688(In the case of split screens, the default scrolling distance is
689corrected to half the current screen size.)
690It is an error if the movement is past the beginning of the file.
691@table @asis
692@item Line:
693Set to the current line minus the amount scrolled.
694@item Column:
695Set to the first nonblank character in the line.
696@item Options:
697None.
698@end table
699@end deftypefn
700@cindex <control-W>
701@deftypefn Command {} {<control-W>}
702
703Switch to the next lower screen in the window, or, to the first
704screen if there are no lower screens in the window.
705@table @asis
706@item Line:
707Set to the previous cursor position in the window.
708@item Column:
709Set to the previous cursor position in the window.
710@item Options:
711None.
712@end table
713@end deftypefn
714@cindex <control-Y>
715@deftypefn Command {[count]} {<control-Y>}
716
717Scroll backward
718@LI{count}lines, leaving the current line and column as is, if possible.
719It is an error if the movement is past the beginning of the file.
720@table @asis
721@item Line:
722Unchanged unless the current line scrolls off the screen,
723in which case it is set to the last line of text displayed
724on the screen.
725@item Column:
726Unchanged unless the current line scrolls off the screen,
727in which case it is the most attractive cursor position.
728@item Options:
729None.
730@end table
731@end deftypefn
732@cindex <control-Z>
733@deftypefn Command {} {<control-Z>}
734
735Suspend the current editor session.
736If the file has been modified since it was last completely written,
737and the
738@OP{autowrite}
739option is set, the file is written before the editor session is
740suspended.
741If this write fails, the editor session is not suspended.
742@table @asis
743@item Line:
744Unchanged.
745@item Column:
746Unchanged.
747@item Options:
748Affected by the
749@OP{autowrite}
750option.
751@end table
752@end deftypefn
753@cindex <escape>
754@deftypefn Command {} {<escape>}
755
756Execute
757@CO{ex}
758commands or cancel partial commands.
759If an
760@CO{ex}
761command is being entered (e.g.
762@CO{/},
763@CO{?},
764@CO{:}
765or
766@CO{!}),
767the command is executed.
768If a partial command has been entered, e.g.
769@QT{[0-9]*},
770or
771@QT{[0-9]*[!<>cdy]},
772the command is cancelled.
773Otherwise, it is an error.
774@table @asis
775@item Line:
776When an
777@CO{ex}
778command is being executed, the current line is set as described for
779that command.
780Otherwise, unchanged.
781@item Column:
782When an
783@CO{ex}
784command is being executed, the current column is set as described for
785that command.
786Otherwise, unchanged.
787@item Options:
788None.
789@end table
790@end deftypefn
791@cindex <control-]>
792@deftypefn Command {} {<control-]>}
793
794Push a tag reference onto the tag stack.
795The tags files (see the
796@OP{tags}
797option for more information) are searched for a tag matching the
798current word.
799The current word begins at the first non-whitespace character on or
800after the current cursor position,
801and extends up to the next non-word character or the end of the line.
802If a matching tag is found, the current file is discarded and the
803file containing the tag reference is edited.
804@sp 1
805If the current file has been modified since it was last completely
806written, the command will fail.
807The
808@CO{<control-]>}
809command is an absolute movement.
810@table @asis
811@item Line:
812Set to the line containing the matching tag string.
813@item Column:
814Set to the start of the matching tag string.
815@item Options:
816Affected by the
817@OP{tags}
818and
819@OP{taglength}
820options.
821@end table
822@end deftypefn
823@cindex <control-^>
824@deftypefn Command {} {<control-^>}
825
826Switch to the most recently edited file.
827@sp 1
828If the file has been modified since it was last completely written,
829and the
830@OP{autowrite}
831option is set, the file is written out.
832If this write fails, the command will fail.
833Otherwise, if the current file has been modified since it was last
834completely written, the command will fail.
835@table @asis
836@item Line:
837Set to the line the cursor was on when the file was last edited.
838@item Column:
839Set to the column the cursor was on when the file was last edited.
840@item Options:
841Affected by the
842@OP{autowrite}
843option.
844@end table
845@end deftypefn
846@cindex <space>
847@deftypefn Command {[count]} {<space>}
848
849@cindex l
850@deftypefnx Command  {[count]} {l}
851Move the cursor forward
852@LI{count}characters without changing the current line.
853It is an error if the cursor is on the last character in the line.
854@sp 1
855The
856@CO{<space>}
857and
858@CO{l}
859commands may be used as the motion component of other
860@CO{vi}
861commands, in which case any text copied into a buffer is
862character oriented.
863In addition, these commands may be used as the motion components
864of other commands when the cursor is on the last character in the
865line, without error.
866@table @asis
867@item Line:
868Unchanged.
869@item Column:
870Set to the current character plus the next
871@LI{count}characters, or to the last character on the line if
872@LI{count}is greater than the number of characters in the line after the
873current character.
874@item Options:
875None.
876@end table
877@end deftypefn
878@cindex !
879@deftypefn Command {[count]} {!} {motion shell-argument(s)<carriage-return>}
880
881Replace text with results from a shell command.
882Pass the lines specified by the
883@LI{count}and
884@LI{motion}arguments as standard input to the program named by the
885@OP{shell}
886option, and replace those lines with the output (both
887standard error and standard output) of that command.
888@sp 1
889After the motion is entered,
890@CO{vi}
891prompts for arguments to the shell command.
892@sp 1
893Within those arguments,
894@QT{%}
895and
896@QT{#}
897characters are expanded to the current and alternate pathnames,
898respectively.
899The
900@QT{!}
901character is expanded with the command text of the previous
902@CO{!}
903or
904@CO{:!}
905commands.
906(Therefore, the command
907@CO{!<motion>!}
908repeats the previous
909@CO{!}
910command.)
911The special meanings of
912@QT{%},
913@QT{#}
914and
915@QT{!}
916can be overridden by escaping them with a backslash.
917If no
918@CO{!}
919or
920@CO{:!}
921command has yet been executed,
922it is an error to use an unescaped
923@QT{!}
924character as a shell argument.
925The
926@CO{!}
927command does
928@emph{not}
929do shell expansion on the strings provided as arguments.
930If any of the above expansions change the arguments the user entered,
931the command is redisplayed at the bottom of the screen.
932@sp 1
933@CO{Vi}
934then executes the program named by the
935@OP{shell}
936option, with a
937@strong{-c}
938flag followed by the arguments (which are bundled into a single argument).
939@sp 1
940The
941@CO{!}
942command is permitted in an empty file.
943@sp 1
944If the file has been modified since it was last completely written,
945the
946@CO{!}
947command will warn you.
948@table @asis
949@item Line:
950The first line of the replaced text.
951@item Column:
952The first column of the replaced text.
953@item Options:
954Affected by the
955@OP{shell}
956option.
957@end table
958@end deftypefn
959@cindex #
960@deftypefn Command {[count]} {#} {#|+|-}
961
962Increment or decrement the number referenced by the cursor.
963If the trailing character is a
964@LI{+}or
965@LI{#},
966the number is incremented by
967@LI{count}.
968If the trailing character is a
969@LI{-},
970the number is decremented by
971@LI{count}.
972@sp 1
973A leading
974@QT{0X}
975or
976@QT{0x}
977causes the number to be interpreted as a hexadecimal number.
978Otherwise, a leading
979@QT{0}
980causes the number to be interpreted as an octal number, unless a non-octal
981digit is found as part of the number.
982Otherwise, the number is interpreted as a decimal number, and may
983have a leading
984@LI{+}or
985@LI{-}sign.
986The current number begins at the first non-blank character at or after
987the current cursor position, and extends up to the end of the line or
988the first character that isn't a possible character for the numeric type.
989The format of the number (e.g. leading 0's, signs) is retained unless
990the new value cannot be represented in the previous format.
991@sp 1
992Octal and hexadecimal numbers, and the result of the operation, must fit
993into an
994@QT{unsigned long}.
995Similarly, decimal numbers and their result must fit into a
996@QT{signed long}.
997It is an error to use this command when the cursor is not positioned at
998a number.
999@sp 1
1000@table @asis
1001@item Line:
1002Unchanged.
1003@item Column:
1004Set to the first character in the cursor number.
1005@item Options:
1006None.
1007@end table
1008@end deftypefn
1009@cindex $
1010@deftypefn Command {[count]} {$}
1011
1012Move the cursor to the end of a line.
1013If
1014@LI{count}is specified, the cursor moves down
1015@LI{count - 1}lines.
1016@sp 1
1017It is not an error to use the
1018@CO{$}
1019command when the cursor is on the last character in the line or
1020when the line is empty.
1021@sp 1
1022The
1023@CO{$}
1024command may be used as the motion component of other
1025@CO{vi}
1026commands, in which case any text copied into a buffer is
1027character oriented, unless the cursor is at, or before the first
1028nonblank character in the line, in which case it is line oriented.
1029It is not an error to use the
1030@CO{$}
1031command as a motion component when the cursor is on the last character
1032in the line, although it is an error when the line is empty.
1033@table @asis
1034@item Line:
1035Set to the current line plus
1036@LI{count}minus 1.
1037@item Column:
1038Set to the last character in the line.
1039@item Options:
1040None.
1041@end table
1042@end deftypefn
1043@cindex %
1044@deftypefn Command {} {%}
1045
1046Move to the matching character.
1047The cursor moves to the bracket character which
1048@emph{matches}
1049the bracket found at the current cursor position
1050or which is the closest one to the right of the cursor on the line.
1051The bracket characters are defined by the
1052@OP{matchchars}
1053option.
1054An error will be reported if none of the
1055@OP{matchchars}
1056characters is found, or if no matching character is found.
1057If the open and close brackes are identical (e.g.: if they are
1058@QT{'}
1059or
1060@QT{"},
1061then repeating a
1062@CO{%}
1063command will perform a backwards search from the original opening bracket.
1064Historically, any
1065@LI{count}specified to the
1066@CO{%}
1067command was ignored.
1068@sp 1
1069The
1070@CO{%}
1071command is an absolute movement.
1072The
1073@CO{%}
1074command may be used as the motion component of other
1075@CO{vi}
1076commands, in which case any text copied into a buffer is
1077character oriented, unless the starting point of the region is at
1078or before the first nonblank character on its line, and the ending
1079point is at or after the last nonblank character on its line, in
1080which case it is line oriented.
1081@table @asis
1082@item Line:
1083Set to the line containing the matching character.
1084@item Column:
1085Set to the matching character.
1086@item Options:
1087None.
1088@end table
1089@end deftypefn
1090@cindex &
1091@deftypefn Command {} {&}
1092
1093Repeat the previous substitution command on the current line.
1094@sp 1
1095Historically, any
1096@LI{count}specified to the
1097@CO{&}
1098command was ignored.
1099@table @asis
1100@item Line:
1101Unchanged.
1102@item Column:
1103Unchanged if the cursor was on the last character in the line,
1104otherwise, set to the first nonblank character in the line.
1105@item Options:
1106Affected by the
1107@OP{edcompatible},
1108@OP{extended},
1109@OP{ignorecase}
1110and
1111@OP{magic}
1112options.
1113@end table
1114@end deftypefn
1115@cindex SQUOTE<character>
1116@deftypefn Command {} {'<character>}
1117
1118@cindex `<character>
1119@deftypefnx Command {} `<character>
1120Return to a context marked by the character
1121@LI{<character>}.
1122If
1123@LI{<character>}is the
1124@QT{'}
1125or
1126@QT{`}
1127character, return to the previous context.
1128If
1129@LI{<character>}is any other character,
1130return to the context marked by that character (see the
1131@CO{m}
1132command for more information).
1133If the command is the
1134@CO{\'}
1135command, only the line value is restored,
1136and the cursor is placed on the first nonblank character of that line.
1137If the command is the
1138@CO{`}
1139command, both the line and column values are restored.
1140@sp 1
1141It is an error if the context no longer exists because of
1142line deletion.
1143(Contexts follow lines that are moved, or which are deleted
1144and then restored.)
1145@sp 1
1146The
1147@CO{\'}
1148and
1149@CO{`}
1150commands are both absolute movements.
1151They may be used as a motion component for other
1152@CO{vi}
1153commands.
1154For the
1155@CO{\'}
1156command, any text copied into a buffer is line oriented.
1157For the
1158@CO{`}
1159command,
1160any text copied into a buffer is character oriented,
1161unless it both starts and stops at the first character in the line,
1162in which case it is line oriented.
1163In addition, when using the
1164@CO{`}
1165command as a motion component,
1166commands which move backward and started at the first character in the line,
1167or move forward and ended at the first character in the line,
1168are corrected to the last character of the line preceding the starting and
1169ending lines, respectively.
1170@table @asis
1171@item Line:
1172Set to the line from the context.
1173@item Column:
1174Set to the first nonblank character in the line, for the
1175@CO{\'}
1176command, and set to the context's column for the
1177@CO{`}
1178command.
1179@item Options:
1180None.
1181@end table
1182@end deftypefn
1183@cindex (
1184@deftypefn Command {} {[count] (}
1185
1186Back up
1187@LI{count}sentences.
1188@sp 1
1189The
1190@CO{(}
1191command is an absolute movement.
1192The
1193@CO{(}
1194command may be used as the motion component of other
1195@CO{vi}
1196commands,
1197in which case any text copied into a buffer is character oriented,
1198unless the starting and stopping points of the region are the first
1199character in the line,
1200in which case it is line oriented.
1201If it is line oriented,
1202the starting point of the region is adjusted to be the end of the line
1203immediately before the starting cursor position.
1204@table @asis
1205@item Line:
1206Set to the line containing the beginning of the sentence.
1207@item Column:
1208Set to the first nonblank character of the sentence.
1209@item Options:
1210Affected by the
1211@OP{lisp}
1212option.
1213@end table
1214@end deftypefn
1215@cindex )
1216@deftypefn Command {[count]} {)}
1217
1218Move forward
1219@LI{count}sentences.
1220@sp 1
1221The
1222@CO{)}
1223command is an absolute movement.
1224The
1225@CO{)}
1226command may be used as the motion component of other
1227@CO{vi}
1228commands, in which case any text copied into a buffer is
1229character oriented, unless the starting point of the region is the
1230first character in the line, in which case it is line oriented.
1231In the latter case, if the stopping point of the region is also
1232the first character in the line, it is adjusted to be the end of the
1233line immediately before it.
1234@table @asis
1235@item Line:
1236Set to the line containing the beginning of the sentence.
1237@item Column:
1238Set to the first nonblank character of the sentence.
1239@item Options:
1240Affected by the
1241@OP{lisp}
1242option.
1243@end table
1244@end deftypefn
1245@cindex ,
1246@deftypefn Command {[count]} {,}
1247
1248Reverse find character
1249@LI{count}times.
1250Reverse the last
1251@CO{F},
1252@CO{f},
1253@CO{T}
1254or
1255@CO{t}
1256command, searching the other way in the line,
1257@LI{count}times.
1258It is an error if a
1259@CO{F},
1260@CO{f},
1261@CO{T}
1262or
1263@CO{t}
1264command has not been performed yet.
1265@sp 1
1266The
1267@CO{,}
1268command may be used as the motion component of other
1269@CO{vi}
1270commands, in which case any text copied into a buffer is
1271character oriented.
1272@table @asis
1273@item Line:
1274Unchanged.
1275@item Column:
1276Set to the searched-for character for the
1277@CO{F}
1278and
1279@CO{f}
1280commands,
1281before the character for the
1282@CO{t}
1283command
1284and after the character for the
1285@CO{T}
1286command.
1287@item Options:
1288None.
1289@end table
1290@end deftypefn
1291@cindex MINUSSIGN
1292@deftypefn Command {[count]} {-}
1293
1294Move to the first nonblank of the previous line,
1295@LI{count}times.
1296@sp 1
1297It is an error if the movement is past the beginning of the file.
1298@sp 1
1299The
1300@CO{-}
1301command may be used as the motion component of other
1302@CO{vi}
1303commands, in which case any text copied into a buffer is
1304line oriented.
1305@table @asis
1306@item Line:
1307Set to the current line minus
1308@LI{count}.
1309@item Column:
1310Set to the first nonblank character in the line.
1311@item Options:
1312None.
1313@end table
1314@end deftypefn
1315@cindex .
1316@deftypefn Command {[count]} {.}
1317
1318Repeat the last
1319@CO{vi}
1320command that modified text.
1321The repeated command may be a command and motion component combination.
1322If
1323@LI{count}is specified, it replaces
1324@emph{both}
1325the count specified for the repeated command, and, if applicable, for
1326the repeated motion component.
1327If
1328@LI{count}is not specified, the counts originally specified to the command being
1329repeated are used again.
1330@sp 1
1331As a special case, if the
1332@CO{\.}
1333command is executed immediately after the
1334@CO{u}
1335command, the change log is rolled forward or backward, depending on
1336the action of the
1337@CO{u}
1338command.
1339@table @asis
1340@item Line:
1341Set as described for the repeated command.
1342@item Column:
1343Set as described for the repeated command.
1344@item Options:
1345None.
1346@end table
1347@end deftypefn
1348@cindex /RE/
1349@deftypefn Command {} {/RE<carriage-return>}
1350
1351@deftypefnx Command {} {/RE/} {[offset]<carriage-return>}
1352@cindex ?RE?
1353@deftypefnx Command {}  {?RE<carriage-return>}
1354@deftypefnx Command {} {?RE?} {[offset]<carriage-return>}
1355@cindex N
1356@deftypefnx Command  {} N
1357@cindex n
1358@deftypefnx Command  {} n
1359Search forward or backward for a regular expression.
1360The commands beginning with a slash
1361@PQ{/}
1362character are forward searches, the commands beginning with a
1363question mark
1364@PQ{?}
1365are backward searches.
1366@CO{Vi}
1367prompts with the leading character on the last line of the screen
1368for a string.
1369It then searches forward or backward in the file for the next
1370occurrence of the string, which is interpreted as a Basic Regular
1371Expression.
1372@sp 1
1373The
1374@CO{/}
1375and
1376@CO{?}
1377commands are absolute movements.
1378They may be used as the motion components of other
1379@CO{vi}
1380commands, in which case any text copied into a buffer is
1381character oriented, unless the search started and ended on
1382the first column of a line, in which case it is line oriented.
1383In addition, forward searches ending at the first character of a line,
1384and backward searches beginning at the first character in the line,
1385are corrected to begin or end at the last character of the previous line.
1386(Note, forward and backward searches can occur for both
1387@CO{/}
1388and
1389@CO{?}
1390commands, if the
1391@OP{wrapscan}
1392option is set.)
1393@sp 1
1394If an offset from the matched line is specified (i.e. a trailing
1395@QT{/}
1396or
1397@QT{?}
1398character is followed by a signed offset), the buffer will always
1399be line oriented (e.g.
1400@QT{/string/+0}
1401will always guarantee a line orientation).
1402@sp 1
1403The
1404@CO{N}
1405command repeats the previous search, but in the reverse direction.
1406The
1407@CO{n}
1408command repeats the previous search.
1409If either the
1410@CO{N}
1411or
1412@CO{n}
1413commands are used as motion components for the 
1414@CO{!}
1415command, you will not be prompted for the text of the bang command,
1416instead the previous bang command will be executed.
1417@sp 1
1418Missing RE's (e.g.
1419@QT{//<carriage-return>},
1420@QT{/<carriage-return>},
1421@QT{??<carriage-return>},
1422or
1423@QT{?<carriage-return>}
1424search for the last search RE, in the indicated direction.
1425@sp 1
1426Searches may be interrupted using the
1427@LI{<interrupt>}character.
1428@sp 1
1429Multiple search patterns may be grouped together by delimiting
1430them with semicolons and zero or more whitespace characters, e.g.
1431@LI{/foo/ ; ?bar?}searches forward for
1432@LI{foo}and then, from that location, backwards for
1433@LI{bar}.
1434When search patterns are grouped together in this manner,
1435the search patterns are evaluated left to right with the
1436final cursor position determined by the last search pattern.
1437@sp 1
1438It is also permissible to append a
1439@CO{z}
1440command to the search strings, e.g.
1441@LI{/foo/ z.}searches forward for the next occurrence of
1442@LI{foo},
1443and then positions that line in the middle of screen.
1444@table @asis
1445@item Line:
1446Set to the line in which the match occurred.
1447@item Column:
1448Set to the first character of the matched string.
1449@item Options:
1450Affected by the
1451@OP{edcompatible},
1452@OP{extended},
1453@OP{ignorecase},
1454@OP{magic},
1455and
1456@OP{wrapscan}
1457options.
1458@end table
1459@end deftypefn
1460@cindex 0
1461@deftypefn Command {} {0}
1462
1463Move to the first character in the current line.
1464It is not an error to use the
1465@CO{0}
1466command when the cursor is on the first character in the line,
1467@sp 1
1468The
1469@CO{0}
1470command may be used as the motion component of other
1471@CO{vi}
1472commands,
1473in which case it is an error if the cursor is on the first character
1474in the line,
1475and any text copied into a buffer is character oriented.
1476@table @asis
1477@item Line:
1478Unchanged.
1479@item Column:
1480Set to the first character in the line.
1481@item Options:
1482None.
1483@end table
1484@end deftypefn
1485@cindex :
1486@deftypefn Command {} {:}
1487
1488Execute an
1489@CO{ex}
1490command.
1491@CO{Vi}
1492prompts for an
1493@CO{ex}
1494command on the last line of the screen, using a colon
1495@PQ{:}
1496character.
1497The command is terminated by a
1498@LI{<carriage-return>},
1499@LI{<newline>}or
1500@LI{<escape>}character; all of these characters may be escaped by using a
1501@LI{<literal-next>}character.
1502The command is then executed.
1503@sp 1
1504If the
1505@CO{ex}
1506command writes to the screen,
1507@CO{vi}
1508will prompt the user for a
1509@LI{<carriage-return>}before continuing
1510when the
1511@CO{ex}
1512command finishes.
1513Large amounts of output from the
1514@CO{ex}
1515command will be paged for the user, and the user prompted for a
1516@LI{<carriage-return>}or
1517@LI{<space>}key to continue.
1518In some cases, a quit (normally a
1519@QQ{q}
1520character) or
1521@LI{<interrupt>}may be entered to interrupt the
1522@CO{ex}
1523command.
1524@sp 1
1525When the
1526@CO{ex}
1527command finishes, and the user is prompted to resume visual mode,
1528it is also possible to enter another
1529@QT{:}
1530character followed by another
1531@CO{ex}
1532command.
1533@table @asis
1534@item Line:
1535The current line is set as described for the
1536@CO{ex}
1537command.
1538@item Column:
1539The current column is set as described for the
1540@CO{ex}
1541command.
1542@item Options:
1543Affected as described for the
1544@CO{ex}
1545command.
1546@end table
1547@end deftypefn
1548@cindex ;
1549@deftypefn Command {[count]} {;}
1550
1551Repeat the last character find
1552@LI{count}times.
1553The last character find is one of the
1554@CO{F},
1555@CO{f},
1556@CO{T}
1557or
1558@CO{t}
1559commands.
1560It is an error if a
1561@CO{F},
1562@CO{f},
1563@CO{T}
1564or
1565@CO{t}
1566command has not been performed yet.
1567@sp 1
1568The
1569@CO{;}
1570command may be used as the motion component of other
1571@CO{vi}
1572commands, in which case any text copied into a buffer is
1573character oriented.
1574@table @asis
1575@item Line:
1576Unchanged.
1577@item Column:
1578Set to the searched-for character for the
1579@CO{F}
1580and
1581@CO{f}
1582commands,
1583before the character for the
1584@CO{t}
1585command
1586and after the character for the
1587@CO{T}
1588command.
1589@item Options:
1590None.
1591@end table
1592@end deftypefn
1593@cindex <
1594@deftypefn Command {[count]} {< motion}
1595
1596@cindex >
1597@deftypefnx Command  {[count]} {>} {motion}
1598Shift lines left or right.
1599Shift the number of lines in the region specified by the
1600@LI{count}and
1601@LI{motion}left (for the
1602@CO{<}
1603command) or right (for the
1604@CO{>}
1605command) by the number of columns specified by the
1606@OP{shiftwidth}
1607option.
1608Only whitespace characters are deleted when shifting left.
1609Once the first character in the line no longer contains a whitespace
1610character, the command will succeed,
1611but the line will not be modified.
1612@table @asis
1613@item Line:
1614Unchanged.
1615@item Column:
1616Set to the first nonblank character in the line.
1617@item Options:
1618Affected by the
1619@OP{shiftwidth}
1620option.
1621@end table
1622@end deftypefn
1623@cindex @@
1624@deftypefn Command {} {@@} {buffer}
1625
1626Execute a named buffer.
1627Execute the named buffer as
1628@CO{vi}
1629commands.
1630The buffer may include
1631@CO{ex}
1632commands, too, but they must be expressed as a
1633@CO{:}
1634command.
1635If the buffer is line oriented,
1636@LI{<newline>}characters are logically appended to each line of the buffer.
1637If the buffer is character oriented,
1638@LI{<newline>}characters are logically appended to all but the last line in the buffer.
1639@sp 1
1640If the buffer name is
1641@QT{@@},
1642or
1643@QT{*},
1644then the last buffer executed shall be used.
1645It is an error to specify
1646@QT{@@@@}
1647or
1648@QT{@@*}
1649if there were no previous buffer executions.
1650The text of a buffer may contain a
1651@CO{@@}
1652command,
1653and it is possible to create infinite loops in this manner.
1654(The
1655@LI{<interrupt>}character may be used to interrupt the loop.)
1656@table @asis
1657@item Line:
1658The current line is set as described for the command(s).
1659@item Column:
1660The current column is set as described for the command(s).
1661@item Options:
1662None.
1663@end table
1664@end deftypefn
1665@cindex A
1666@deftypefn Command {[count]} {A}
1667
1668Enter input mode, appending the text after the end of the line.
1669If
1670@LI{count}is specified, the text is repeatedly input
1671@LI{count - 1}more times after input mode is exited.
1672@table @asis
1673@item Line:
1674Set to the last line upon which characters were entered.
1675@item Column:
1676Set to the last character entered.
1677@item Options:
1678Affected by the
1679@OP{altwerase},
1680@OP{autoindent},
1681@OP{beautify},
1682@OP{showmatch},
1683@OP{ttywerase}
1684and
1685@OP{wrapmargin}
1686options.
1687@end table
1688@end deftypefn
1689@cindex B
1690@deftypefn Command {[count]} {B}
1691
1692Move backward
1693@LI{count}bigwords.
1694Move the cursor backward to the beginning of a bigword by repeating the
1695following algorithm: if the current position is at the beginning of a
1696bigword or the character at the current position cannot be part of a bigword,
1697move to the first character of the preceding bigword.
1698Otherwise, move to the first character of the bigword at the current position.
1699If no preceding bigword exists on the current line, move to the first
1700character of the last bigword on the first preceding line that contains a
1701bigword.
1702@sp 1
1703The
1704@CO{B}
1705command may be used as the motion component of other
1706@CO{vi}
1707commands, in which case any text copied into a buffer is
1708character oriented.
1709@table @asis
1710@item Line:
1711Set to the line containing the word selected.
1712@item Column:
1713Set to the first character of the word selected.
1714@item Options:
1715None.
1716@end table
1717@end deftypefn
1718@cindex C
1719@deftypefn Command {[buffer]} {[count] C}
1720
1721Change text from the current position to the end-of-line.
1722If
1723@LI{count}is specified, the input text replaces from the current position to
1724the end-of-line, plus
1725@LI{count - 1}subsequent lines.
1726@table @asis
1727@item Line:
1728Set to the last line upon which characters were entered.
1729@item Column:
1730Set to the last character entered.
1731@item Options:
1732Affected by the
1733@OP{altwerase},
1734@OP{autoindent},
1735@OP{beautify},
1736@OP{showmatch},
1737@OP{ttywerase}
1738and
1739@OP{wrapmargin}
1740options.
1741@end table
1742@end deftypefn
1743@cindex D
1744@deftypefn Command {[buffer]} {D}
1745
1746Delete text from the current position to the end-of-line.
1747@sp 1
1748It is not an error to execute the
1749@CO{D}
1750command on an empty line.
1751@table @asis
1752@item Line:
1753Unchanged.
1754@item Column:
1755Set to the character before the current character, or, column 1 if
1756the cursor was on column 1.
1757@item Options:
1758None.
1759@end table
1760@end deftypefn
1761@cindex E
1762@deftypefn Command {[count]} {E}
1763
1764Move forward
1765@LI{count}end-of-bigwords.
1766Move the cursor forward to the end of a bigword by repeating the
1767following algorithm: if the current position is the end of a
1768bigword or the character at that position cannot be part of a bigword,
1769move to the last character of the following bigword.
1770Otherwise, move to the last character of the bigword at the current
1771position.
1772If no succeeding bigword exists on the current line,
1773move to the last character of the first bigword on the next following
1774line that contains a bigword.
1775@sp 1
1776The
1777@CO{E}
1778command may be used as the motion component of other
1779@CO{vi}
1780commands, in which case any text copied into a buffer is
1781character oriented.
1782@table @asis
1783@item Line:
1784Set to the line containing the word selected.
1785@item Column:
1786Set to the last character of the word selected.
1787@item Options:
1788None.
1789@end table
1790@end deftypefn
1791@cindex F
1792@deftypefn Command {[count]} {F} {<character>}
1793
1794Search
1795@LI{count}times backward through the current line for
1796@LI{<character>}.
1797@sp 1
1798The
1799@CO{F}
1800command may be used as the motion component of other
1801@CO{vi}
1802commands, in which case any text copied into a buffer is
1803character oriented.
1804@table @asis
1805@item Line:
1806Unchanged.
1807@item Column:
1808Set to the searched-for character.
1809@item Options:
1810None.
1811@end table
1812@end deftypefn
1813@cindex G
1814@deftypefn Command {[count]} {G}
1815
1816Move to line
1817@LI{count},
1818or the last line of the file if
1819@LI{count}not specified.
1820@sp 1
1821The
1822@CO{G}
1823command is an absolute movement.
1824The
1825@CO{G}
1826command may be used as the motion component of other
1827@CO{vi}
1828commands, in which case any text copied into a buffer is
1829line oriented.
1830@table @asis
1831@item Line:
1832Set to
1833@LI{count},
1834if specified, otherwise, the last line.
1835@item Column:
1836Set to the first nonblank character in the line.
1837@item Options:
1838None.
1839@end table
1840@end deftypefn
1841@cindex H
1842@deftypefn Command {[count]} {H}
1843
1844Move to the screen line
1845@LI{count - 1}lines below the top of the screen.
1846@sp 1
1847The
1848@CO{H}
1849command is an absolute movement.
1850The
1851@CO{H}
1852command may be used as the motion component of other
1853@CO{vi}
1854commands, in which case any text copied into a buffer is
1855line oriented.
1856@table @asis
1857@item Line:
1858Set to the line
1859@LI{count - 1}lines below the top of the screen.
1860@item Column:
1861Set to the first nonblank character of the
1862@emph{screen}
1863line.
1864@item Options:
1865None.
1866@end table
1867@end deftypefn
1868@cindex I
1869@deftypefn Command {[count]} {I}
1870
1871Enter input mode, inserting the text at the beginning of the line.
1872If
1873@LI{count}is specified, the text input is repeatedly input
1874@LI{count - 1}more times.
1875@table @asis
1876@item Line:
1877Set to the last line upon which characters were entered.
1878@item Column:
1879Set to the last character entered.
1880@item Options:
1881None.
1882@end table
1883@end deftypefn
1884@cindex J
1885@deftypefn Command {[count]} {J}
1886
1887Join lines.
1888If
1889@LI{count}is specified,
1890@LI{count}lines are joined; a minimum of two lines are always joined,
1891regardless of the value of
1892@LI{count}.
1893@sp 1
1894If the current line ends with a whitespace character, all whitespace
1895is stripped from the next line.
1896Otherwise, if the next line starts with a open parenthesis
1897@PQ{(}
1898do nothing.
1899Otherwise, if the current line ends with a question mark
1900@PQ{?},
1901period
1902@PQ{.}
1903or exclamation point
1904@PQ{!},
1905insert two spaces.
1906Otherwise, insert a single space.
1907@sp 1
1908It is not an error to join lines past the end of the file,
1909i.e. lines that do not exist.
1910@table @asis
1911@item Line:
1912Unchanged.
1913@item Column:
1914Set to the character after the last character of the next-to-last
1915joined line.
1916@item Options:
1917None.
1918@end table
1919@end deftypefn
1920@cindex L
1921@deftypefn Command {[count]} {L}
1922
1923Move to the screen line
1924@LI{count - 1}lines above the bottom of the screen.
1925@sp 1
1926The
1927@CO{L}
1928command is an absolute movement.
1929The
1930@CO{L}
1931command may be used as the motion component of other
1932@CO{vi}
1933commands, in which case any text copied into a buffer is
1934line oriented.
1935@table @asis
1936@item Line:
1937Set to the line
1938@LI{count - 1}lines above the bottom of the screen.
1939@item Column:
1940Set to the first nonblank character of the
1941@emph{screen}
1942line.
1943@item Options:
1944None.
1945@end table
1946@end deftypefn
1947@cindex  M
1948@deftypefn Command {} {M}
1949
1950Move to the screen line in the middle of the screen.
1951@sp 1
1952The
1953@CO{M}
1954command is an absolute movement.
1955The
1956@CO{M}
1957command may be used as the motion component of other
1958@CO{vi}
1959commands, in which case any text copied into a buffer is
1960line oriented.
1961@sp 1
1962Historically, any
1963@LI{count}specified to the
1964@CO{M}
1965command was ignored.
1966@table @asis
1967@item Line:
1968Set to the line in the middle of the screen.
1969@item Column:
1970Set to the first nonblank character of the
1971@emph{screen}
1972line.
1973@item Options:
1974None.
1975@end table
1976@end deftypefn
1977@cindex O
1978@deftypefn Command {[count]} {O}
1979
1980Enter input mode, appending text in a new line above the current line.
1981If
1982@LI{count}is specified, the text input is repeatedly input
1983@LI{count - 1}more times.
1984@sp 1
1985Historically, any
1986@LI{count}specified to the
1987@CO{O}
1988command was ignored.
1989@table @asis
1990@item Line:
1991Set to the last line upon which characters were entered.
1992@item Column:
1993Set to the last character entered.
1994@item Options:
1995Affected by the
1996@OP{altwerase},
1997@OP{autoindent},
1998@OP{beautify},
1999@OP{showmatch},
2000@OP{ttywerase}
2001and
2002@OP{wrapmargin}
2003options.
2004@end table
2005@end deftypefn
2006@cindex P
2007@deftypefn Command {[buffer]} {P}
2008
2009Insert text from a buffer.
2010Text from the buffer (the unnamed buffer by default) is inserted
2011before the current column or, if the buffer is line oriented,
2012before the current line.
2013@table @asis
2014@item Line:
2015Set to the lowest numbered line insert,
2016if the buffer is line oriented, otherwise unchanged.
2017@item Column:
2018Set to the first nonblank character of the appended text,
2019if the buffer is line oriented, otherwise, the last character
2020of the appended text.
2021@item Options:
2022None.
2023@end table
2024@end deftypefn
2025@cindex Q
2026@deftypefn Command {} {Q}
2027
2028Exit
2029@CO{vi}
2030(or visual) mode and switch to
2031@CO{ex}
2032mode.
2033@table @asis
2034@item Line:
2035Unchanged.
2036@item Column:
2037No longer relevant.
2038@item Options:
2039None.
2040@end table
2041@end deftypefn
2042@cindex R
2043@deftypefn Command {[count]} {R}
2044
2045Enter input mode, replacing the characters in the current line.
2046If
2047@LI{count}is specified, the text input is repeatedly input
2048@LI{count - 1}more times.
2049@sp 1
2050If the end of the current line is reached, no more characters are
2051replaced and any further characters input are appended to the line.
2052@table @asis
2053@item Line:
2054Set to the last line upon which characters were entered.
2055@item Column:
2056Set to the last character entered.
2057@item Options:
2058Affected by the
2059@OP{altwerase},
2060@OP{autoindent},
2061@OP{beautify},
2062@OP{showmatch},
2063@OP{ttywerase}
2064and
2065@OP{wrapmargin}
2066options.
2067@end table
2068@end deftypefn
2069@cindex S
2070@deftypefn Command {[buffer] [count]} {S}
2071
2072Substitute
2073@LI{count}lines.
2074@table @asis
2075@item Line:
2076Set to the last line upon which characters were entered.
2077@item Column:
2078Set to the last character entered.
2079@item Options:
2080Affected by the
2081@OP{altwerase},
2082@OP{autoindent},
2083@OP{beautify},
2084@OP{showmatch},
2085@OP{ttywerase}
2086and
2087@OP{wrapmargin}
2088options.
2089@end table
2090@end deftypefn
2091@cindex T
2092@deftypefn Command {[count]} {T} {<character>}
2093
2094Search backward,
2095@LI{count}times,
2096through the current line for the character
2097@emph{after}
2098the specified
2099@LI{<character>}.
2100@sp 1
2101The
2102@CO{T}
2103command may be used as the motion component of other
2104@CO{vi}
2105commands, in which case any text copied into a buffer is
2106character oriented.
2107@table @asis
2108@item Line:
2109Unchanged.
2110@item Column:
2111Set to the character
2112@emph{after}
2113the searched-for character.
2114@item Options:
2115None.
2116@end table
2117@end deftypefn
2118@cindex U
2119@deftypefn Command {} {U}
2120
2121Restore the current line to its state before the cursor last
2122moved to it.
2123@table @asis
2124@item Line:
2125Unchanged.
2126@item Column:
2127The first character in the line.
2128@item Options:
2129None.
2130@end table
2131@end deftypefn
2132@cindex W
2133@deftypefn Command {[count]} {W}
2134
2135Move forward
2136@LI{count}bigwords.
2137Move the cursor forward to the beginning of a bigword by repeating the
2138following algorithm: if the current position is within a bigword or the
2139character at that position cannot be part of a bigword, move to the first
2140character of the next bigword.
2141If no subsequent bigword exists on the current line,
2142move to the first character of the first bigword on the first following
2143line that contains a bigword.
2144@sp 1
2145The
2146@CO{W}
2147command may be used as the motion component of other
2148@CO{vi}
2149commands, in which case any text copied into a buffer is
2150character oriented.
2151@table @asis
2152@item Line:
2153The line containing the word selected.
2154@item Column:
2155The first character of the word selected.
2156@item Options:
2157None.
2158@end table
2159@end deftypefn
2160@cindex X
2161@deftypefn Command {[buffer] [count]} {X}
2162
2163Delete
2164@LI{count}characters before the cursor.
2165If the number of characters to be deleted is greater than or equal to
2166the number of characters to the beginning of the line, all of the
2167characters before the current cursor position, to the beginning of the
2168line, are deleted.
2169@table @asis
2170@item Line:
2171Unchanged.
2172@item Column:
2173Set to the current character minus
2174@LI{count},
2175or the first character if count is greater than the number of
2176characters in the line before the cursor.
2177@item Options:
2178None.
2179@end table
2180@end deftypefn
2181@cindex Y
2182@deftypefn Command {[buffer] [count]} {Y}
2183
2184Copy (or
2185@QQ{yank})
2186@LI{count}lines into the specified buffer.
2187@table @asis
2188@item Line:
2189Unchanged.
2190@item Column:
2191Unchanged.
2192@item Options:
2193None.
2194@end table
2195@end deftypefn
2196@cindex ZZ
2197@deftypefn Command {} {ZZ}
2198
2199Write the file and exit
2200@CO{vi}.
2201The file is only written if it has been modified since the last
2202complete write of the file to any file.
2203@sp 1
2204The
2205@CO{ZZ}
2206command will exit the editor after writing the file,
2207if there are no further files to edit.
2208Entering two
2209@QQ{quit}
2210commands (i.e.
2211@CO{wq},
2212@CO{quit},
2213@CO{xit}
2214or
2215@CO{ZZ})
2216in a row will override this check and the editor will exit,
2217ignoring any files that have not yet been edited.
2218@table @asis
2219@item Line:
2220Unchanged.
2221@item Column:
2222Unchanged.
2223@item Options:
2224None.
2225@end table
2226@end deftypefn
2227@cindex [[
2228@deftypefn Command {[count]} {[[}
2229
2230Back up
2231@LI{count}section boundaries.
2232@sp 1
2233The
2234@CO{[[}
2235command is an absolute movement.
2236The
2237@CO{[[}
2238command may be used as the motion component of other
2239@CO{vi}
2240commands, in which case any text copied into a buffer is
2241character oriented, unless the starting position is column 0,
2242in which case it is line oriented.
2243@sp 1
2244It is an error if the movement is past the beginning of the file.
2245@table @asis
2246@item Line:
2247Set to the previous line that is
2248@LI{count}section boundaries back,
2249or the first line of the file if no more section boundaries exist
2250preceding the current line.
2251@item Column:
2252Set to the first nonblank character in the line.
2253@item Options:
2254Affected by the
2255@OP{sections}
2256option.
2257@end table
2258@end deftypefn
2259@cindex ]]
2260@deftypefn Command {[count]} {]]}
2261
2262Move forward
2263@LI{count}section boundaries.
2264@sp 1
2265The
2266@CO{]]}
2267command is an absolute movement.
2268The
2269@CO{]]}
2270command may be used as the motion component of other
2271@CO{vi}
2272commands, in which case any text copied into a buffer is
2273character oriented, unless the starting position is column 0,
2274in which case it is line oriented.
2275@sp 1
2276It is an error if the movement is past the end of the file.
2277@table @asis
2278@item Line:
2279Set to the line that is
2280@LI{count}section boundaries forward,
2281or to the last line of the file if no more section
2282boundaries exist following the current line.
2283@item Column:
2284Set to the first nonblank character in the line.
2285@item Options:
2286Affected by the
2287@OP{sections}
2288option.
2289@end table
2290@end deftypefn
2291@cindex ^
2292@deftypefn Command {} {^}
2293
2294Move to first nonblank character on the current line.
2295@sp 1
2296The
2297@CO{^}
2298command may be used as the motion component of other
2299@CO{vi}
2300commands, in which case any text copied into a buffer is
2301character oriented.
2302@table @asis
2303@item Line:
2304Unchanged.
2305@item Column:
2306Set to the first nonblank character of the current line.
2307@item Options:
2308None.
2309@end table
2310@end deftypefn
2311@cindex _
2312@deftypefn Command {[count]} {_}
2313
2314Move down
2315@LI{count - 1}lines, to the first nonblank character.
2316The
2317@CO{_}
2318command may be used as the motion component of other
2319@CO{vi}
2320commands, in which case any text copied into a buffer is
2321line oriented.
2322@sp 1
2323It is not an error to execute the
2324@CO{_}
2325command when the cursor is on the first character in the line.
2326@table @asis
2327@item Line:
2328The current line plus
2329@LI{count - 1}.
2330@item Column:
2331The first nonblank character in the line.
2332@item Options:
2333None.
2334@end table
2335@end deftypefn
2336@cindex a
2337@deftypefn Command {[count]} {a}
2338
2339Enter input mode, appending the text after the cursor.
2340If
2341@LI{count}is specified, the text input is repeatedly input
2342@LI{count - 1}more times.
2343@table @asis
2344@item Line:
2345Set to the last line upon which characters were entered.
2346@item Column:
2347Set to the last character entered.
2348@item Options:
2349Affected by the
2350@OP{altwerase},
2351@OP{autoindent},
2352@OP{beautify},
2353@OP{showmatch},
2354@OP{ttywerase}
2355and
2356@OP{wrapmargin}
2357options.
2358@end table
2359@end deftypefn
2360@cindex b
2361@deftypefn Command {[count]} {b}
2362
2363Move backward
2364@LI{count}words.
2365Move the cursor backward to the beginning of a word by repeating the
2366following algorithm: if the current position is at the beginning of a word,
2367move to the first character of the preceding word.
2368Otherwise, the current position moves to the first character of the word
2369at the current position.
2370If no preceding word exists on the current line, move to the first
2371character of the last word on the first preceding line that contains
2372a word.
2373@sp 1
2374The
2375@CO{b}
2376command may be used as the motion component of other
2377@CO{vi}
2378commands, in which case any text copied into a buffer is
2379character oriented.
2380@table @asis
2381@item Line:
2382Set to the line containing the word selected.
2383@item Column:
2384Set to the first character of the word selected.
2385@item Options:
2386None.
2387@end table
2388@end deftypefn
2389@cindex c
2390@deftypefn Command {[buffer] [count]} {c} {motion}
2391
2392Change the region of text specified by the
2393@LI{count}and
2394@LI{motion}.
2395If only part of a single line is affected, then the last character
2396being changed is marked with a
2397@QT{$}.
2398Otherwise, the region of text is deleted, and input mode is entered.
2399@table @asis
2400@item Line:
2401Set to the last line upon which characters were entered.
2402@item Column:
2403Set to the last character entered.
2404@item Options:
2405Affected by the
2406@OP{altwerase},
2407@OP{autoindent},
2408@OP{beautify},
2409@OP{showmatch},
2410@OP{ttywerase}
2411and
2412@OP{wrapmargin}
2413options.
2414@end table
2415@end deftypefn
2416@cindex d
2417@deftypefn Command {[buffer] [count]} {d} {motion}
2418
2419Delete the region of text specified by the
2420@LI{count}and
2421@LI{motion}.
2422@table @asis
2423@item Line:
2424Set to the line where the region starts.
2425@item Column:
2426Set to the first character in the line after the last character in the
2427region.
2428If no such character exists, set to the last character before the region.
2429@item Options:
2430None.
2431@end table
2432@end deftypefn
2433@cindex e
2434@deftypefn Command {[count]} {e}
2435
2436Move forward
2437@LI{count}end-of-words.
2438Move the cursor forward to the end of a word by repeating the following
2439algorithm: if the current position is the end of a word,
2440move to the last character of the following word.
2441Otherwise, move to the last character of the word at the current position.
2442If no succeeding word exists on the current line, move to the last character
2443of the first word on the next following line that contains a word.
2444@sp 1
2445The
2446@CO{e}
2447command may be used as the motion component of other
2448@CO{vi}
2449commands, in which case any text copied into a buffer is
2450character oriented.
2451@table @asis
2452@item Line:
2453Set to the line containing the word selected.
2454@item Column:
2455Set to the last character of the word selected.
2456@item Options:
2457None.
2458@end table
2459@end deftypefn
2460@cindex f
2461@deftypefn Command {[count]} {f} {<character>}
2462
2463Search forward,
2464@LI{count}times, through the rest of the current line for
2465@LI{<character>}.
2466@sp 1
2467The
2468@CO{f}
2469command may be used as the motion component of other
2470@CO{vi}
2471commands, in which case any text copied into a buffer is
2472character oriented.
2473@table @asis
2474@item Line:
2475Unchanged.
2476@item Column:
2477Set to the searched-for character.
2478@item Options:
2479None.
2480@end table
2481@end deftypefn
2482@cindex i
2483@deftypefn Command {[count]} {i}
2484
2485Enter input mode, inserting the text before the cursor.
2486If
2487@LI{count}is specified, the text input is repeatedly input
2488@LI{count - 1}more times.
2489@table @asis
2490@item Line:
2491Set to the last line upon which characters were entered.
2492@item Column:
2493Set to the last character entered.
2494@item Options:
2495Affected by the
2496@OP{altwerase},
2497@OP{autoindent},
2498@OP{beautify},
2499@OP{showmatch},
2500@OP{ttywerase}
2501and
2502@OP{wrapmargin}
2503options.
2504@end table
2505@end deftypefn
2506@cindex m
2507@deftypefn Command {} {m} {<character>}
2508
2509Save the current context (line and column) as
2510@LI{<character>}.
2511The exact position is referred to by
2512@QT{`<character>}.
2513The line is referred to by
2514@QT{'<character>}.
2515@sp 1
2516Historically,
2517@LI{<character>}was restricted to lower-case letters.
2518@CO{Nvi}
2519permits the use of any character.
2520@table @asis
2521@item Line:
2522Unchanged.
2523@item Column:
2524Unchanged.
2525@item Options:
2526None.
2527@end table
2528@end deftypefn
2529@cindex o
2530@deftypefn Command {[count]} {o}
2531
2532Enter input mode, appending text in a new line under the current line.
2533If
2534@LI{count}is specified, the text input is repeatedly input
2535@LI{count - 1}more times.
2536@sp 1
2537Historically, any
2538@LI{count}specified to the
2539@CO{o}
2540command was ignored.
2541@table @asis
2542@item Line:
2543Set to the last line upon which characters were entered.
2544@item Column:
2545Set to the last character entered.
2546@item Options:
2547Affected by the
2548@OP{altwerase},
2549@OP{autoindent},
2550@OP{beautify},
2551@OP{showmatch},
2552@OP{ttywerase}
2553and
2554@OP{wrapmargin}
2555options.
2556@end table
2557@end deftypefn
2558@cindex p
2559@deftypefn Command {[buffer]} {p}
2560
2561Append text from a buffer.
2562Text from the buffer (the unnamed buffer by default) is appended
2563after the current column or, if the buffer is line oriented,
2564after the current line.
2565@table @asis
2566@item Line:
2567Set to the first line appended, if the buffer is line oriented,
2568otherwise unchanged.
2569@item Column:
2570Set to the first nonblank character of the appended text if the buffer
2571is line oriented, otherwise, the last character of the appended text.
2572@item Options:
2573None.
2574@end table
2575@end deftypefn
2576@cindex r
2577@deftypefn Command {[count]} {r} {<character>}
2578
2579Replace characters.
2580The next
2581@LI{count}characters in the line are replaced with
2582@LI{<character>}.
2583Replacing characters with
2584@LI{<newline>}characters results in creating new, empty lines into the file.
2585@sp 1
2586If
2587@LI{<character>}is
2588@LI{<escape>},
2589the command is cancelled.
2590@table @asis
2591@item Line:
2592Unchanged unless the replacement character is a
2593@LI{<newline>},
2594in which case it is set to the current line plus
2595@LI{count - 1}.
2596@item Column:
2597Set to the last character replaced,
2598unless the replacement character is a
2599@LI{<newline>},
2600in which case the cursor is in column 1 of the last line inserted.
2601@item Options:
2602None.
2603@end table
2604@end deftypefn
2605@cindex s
2606@deftypefn Command {[buffer] [count]} {s}
2607
2608Substitute
2609@LI{count}characters in the current line starting with the current character.
2610@table @asis
2611@item Line:
2612Set to the last line upon which characters were entered.
2613@item Column:
2614Set to the last character entered.
2615@item Options:
2616Affected by the
2617@OP{altwerase},
2618@OP{autoindent},
2619@OP{beautify},
2620@OP{showmatch},
2621@OP{ttywerase}
2622and
2623@OP{wrapmargin}
2624options.
2625@end table
2626@end deftypefn
2627@cindex t
2628@deftypefn Command {[count]} {t} {<character>}
2629
2630Search forward,
2631@LI{count}times, through the current line for the character immediately
2632@emph{before}
2633@LI{<character>}.
2634@sp 1
2635The
2636@CO{t}
2637command may be used as the motion component of other
2638@CO{vi}
2639commands, in which case any text copied into a buffer is
2640character oriented.
2641@table @asis
2642@item Line:
2643Unchanged.
2644@item Column:
2645Set to the character
2646@emph{before}
2647the searched-for character.
2648@item Options:
2649None.
2650@end table
2651@end deftypefn
2652@cindex u
2653@deftypefn Command {} {u}
2654
2655Undo the last change made to the file.
2656If repeated, the
2657@CO{u}
2658command alternates between these two states, and is its own inverse.
2659When used after an insert that inserted text on more than one line,
2660the lines are saved in the numeric buffers.
2661@sp 1
2662The
2663@CO{.}
2664command, when used immediately after the
2665@CO{u}
2666command, causes the change log to be rolled forward or backward,
2667depending on the action of the
2668@CO{u}
2669command.
2670@table @asis
2671@item Line:
2672Set to the position of the first line changed, if the reversal affects
2673only one line or represents an addition or change; otherwise, the line
2674preceding the deleted text.
2675@item Column:
2676Set to the cursor position before the change was made.
2677@item Options:
2678None.
2679@end table
2680@end deftypefn
2681@cindex w
2682@deftypefn Command {[count]} {w}
2683
2684Move forward
2685@LI{count}words.
2686Move the cursor forward to the beginning of a word by repeating the
2687following algorithm: if the current position is at the
2688beginning of a word, move to the first character of the next word.
2689If no subsequent word exists on the current line, move to the first
2690character of the first word on the first following line that contains
2691a word.
2692@sp 1
2693The
2694@CO{w}
2695command may be used as the motion component of other
2696@CO{vi}
2697commands, in which case any text copied into a buffer is
2698character oriented.
2699@table @asis
2700@item Line:
2701Set to the line containing the word selected.
2702@item Column:
2703Set to the first character of the word selected.
2704@item Options:
2705None.
2706@end table
2707@end deftypefn
2708@cindex x
2709@deftypefn Command {[buffer] [count]} {x}
2710
2711Delete
2712@LI{count}characters.
2713The deletion is at the current character position.
2714If the number of characters to be deleted is greater than or equal to
2715the number of characters to the end of the line, all of the characters
2716from the current cursor position to the end of the line are deleted.
2717@table @asis
2718@item Line:
2719Unchanged.
2720@item Column:
2721Unchanged unless the last character in the line is deleted and the cursor
2722is not already on the first character in the line, in which case it is
2723set to the previous character.
2724@item Options:
2725None.
2726@end table
2727@end deftypefn
2728@cindex y
2729@deftypefn Command {[buffer] [count]} y {motion}
2730
2731Copy (or
2732@QQ{yank})
2733the text region specified by the
2734@LI{count}and
2735@LI{motion},
2736into a buffer.
2737@table @asis
2738@item Line:
2739Unchanged, unless the region covers more than a single line,
2740in which case it is set to the line where the region starts.
2741@item Column:
2742Unchanged, unless the region covers more than a single line,
2743in which case it is set to the character were the region starts.
2744@item Options:
2745None.
2746@end table
2747@end deftypefn
2748@cindex z
2749@deftypefn Command {[count1]} {z} {[count2] type}
2750
2751Redraw the screen with a window
2752@LI{count2}lines long, with line
2753@LI{count1}placed as specified by the
2754@LI{type}character.
2755If
2756@LI{count1}is not specified, it defaults to the current line.
2757If
2758@LI{count2}is not specified, it defaults to the current window size.
2759@sp 1
2760The following
2761@LI{type}characters may be used:
2762@table @asis
2763@item +
2764If
2765@LI{count1}is specified, place the line
2766@LI{count1}at the top of the screen.
2767Otherwise, display the screen after the current screen, similarly to the
2768@CO{<control-F>}
2769command.
2770@item <carriage-return>
2771Place the line
2772@LI{count1}at the top of the screen.
2773@item .
2774Place the line
2775@LI{count1}in the center of the screen.
2776@item -
2777Place the line
2778@LI{count1}at the bottom of the screen.
2779@item ^
2780If
2781@LI{count1}is specified, place the line that is at the top of the screen 
2782when
2783@LI{count1}is at the bottom of the screen, at the bottom of the screen,
2784i.e. display the screen before the screen before
2785@LI{count1}.
2786Otherwise, display the screen before the current screen, similarly to the
2787@CO{<control-B>}
2788command.
2789@end table
2790@table @asis
2791@item Line:
2792Set to
2793@LI{count1}unless
2794@LI{count1}is not specified and the
2795@LI{type}character was either
2796@QT{^}
2797or
2798@QT{+},
2799in which case it is set to the line before the first line on the
2800previous screen or the line after the last line on the previous
2801screen, respectively.
2802@item Column:
2803Set to the first nonblank character in the line.
2804@item Options:
2805None.
2806@end table
2807@end deftypefn
2808@cindex @{
2809@deftypefn Command {[count]} @{
2810
2811Move backward
2812@LI{count}paragraphs.
2813@sp 1
2814The
2815@strong{@{}
2816command is an absolute movement.
2817The
2818@strong{@{}
2819command may be used as the motion component of other
2820@CO{vi}
2821commands, in which case any text copied into a buffer is
2822character oriented, unless the starting character is the first
2823character on its line, in which case it is line oriented.
2824@table @asis
2825@item Line:
2826Set to the line containing the beginning of the previous paragraph.
2827@item Column:
2828Set to the first nonblank character in the line.
2829@item Options:
2830Affected by the
2831@OP{paragraph}
2832option.
2833@end table
2834@end deftypefn
2835@cindex |
2836@deftypefn Command {[count]} {|}
2837
2838Move to a specific
2839@emph{column}
2840position on the current line.
2841@sp 1
2842The
2843@CO{|}
2844command may be used as the motion component of other
2845@CO{vi}
2846commands, in which case any text copied into a buffer is
2847character oriented.
2848It is an error to use the
2849@CO{|}
2850command as a motion component and for the cursor not to move.
2851@table @asis
2852@item Line:
2853Unchanged.
2854@item Column:
2855Set to the character occupying the column position identified by
2856@LI{count},
2857if the position exists in the line.
2858If the column length of the current line is less than
2859@LI{count},
2860the cursor is moved to the last character in the line.
2861@item Options:
2862None.
2863@end table
2864@end deftypefn
2865@cindex @}
2866@deftypefn Command {[count]} @}
2867
2868Move forward
2869@LI{count}paragraphs.
2870@sp 1
2871The
2872@strong{@}}
2873command is an absolute movement.
2874The
2875@strong{@}}
2876command may be used as the motion component of other
2877@CO{vi}
2878commands, in which case any text copied into a buffer is
2879character oriented, unless the starting character is at or
2880before any nonblank characters in its line,
2881in which case it is line oriented.
2882@table @asis
2883@item Line:
2884Set to the line containing the beginning of the next paragraph.
2885@item Column:
2886Set to the first nonblank character in the line.
2887@item Options:
2888Affected by the
2889@OP{paragraph}
2890option.
2891@end table
2892@end deftypefn
2893@cindex ~
2894@deftypefn Command {[count]} {~}
2895
2896Reverse the case of the next
2897@LI{count}character(s).
2898This is the historic semantic for the
2899@CO{~}
2900command and it is only in effect if the
2901@OP{tildeop}
2902option is not set.
2903@sp 1
2904Lowercase alphabetic characters are changed to uppercase,
2905and uppercase characters are changed to lowercase.
2906No other characters are affected.
2907@sp 1
2908Historically, the
2909@CO{~}
2910command did not take an associated count, nor did it move past the
2911end of the current line.
2912As it had no associated motion it was difficult to change the case
2913of large blocks of text.
2914In
2915@CO{nvi},
2916if the cursor is on the last character of a line, and there are
2917more lines in the file, the cursor moves to the next line.
2918@sp 1
2919It is not an error to specify a count larger than the number of
2920characters between the cursor and the end of the file.
2921@table @asis
2922@item Line:
2923Set to the line of the character after
2924@LI{count}characters, or, end of file.
2925@item Column:
2926Set to the character after
2927@LI{count}characters, or, end-of-file.
2928@item Options:
2929Affected by the
2930@OP{tildeop}
2931option.
2932@end table
2933@end deftypefn
2934@cindex ~
2935@deftypefn Command {[count]} {~} {motion}
2936
2937Reverse the case of the characters in a text region specified by the
2938@LI{count}and
2939@LI{motion}.
2940Only in effect if the
2941@OP{tildeop}
2942option is set.
2943@sp 1
2944Lowercase characters are changed to uppercase,
2945and uppercase characters are changed to lowercase.
2946No other characters are affected.
2947@table @asis
2948@item Line:
2949Set to the line of the character after the last character in the region.
2950@item Column:
2951Set to the character after the last character in the region.
2952@item Options:
2953Affected by the
2954@OP{tildeop}
2955option.
2956@end table
2957@end deftypefn
2958@cindex <interrupt>
2959@deftypefn Command {} {<interrupt>}
2960
2961Interrupt the current operation.
2962Many of the potentially long-running
2963@CO{vi}
2964commands may be interrupted using the terminal interrupt character.
2965These operations include searches, file reading and writing, filter
2966operations and map character expansion.
2967Interrupts are also enabled when running commands outside of
2968@CO{vi}.
2969@sp 1
2970If the
2971@LI{<interrupt>}character is used to interrupt while entering an
2972@CO{ex}
2973command, the command is aborted, the cursor returns to its previous
2974position, and
2975@CO{vi}
2976remains in command mode.
2977@sp 1
2978Generally, if the
2979@LI{<interrupt>}character is used to interrupt any
2980operation, any changes made before the interrupt are left in place.
2981@table @asis
2982@item Line:
2983Dependent on the operation being interrupted.
2984@item Column:
2985Dependent on the operation being interrupted.
2986@item Options:
2987None.
2988@end table
2989@end deftypefn
2990@chapter Vi Text Input Commands
2991
2992The following section describes the commands available in the text
2993input mode of the
2994@CO{vi}
2995editor.
2996
2997Historically,
2998@CO{vi}
2999implementations only permitted the characters inserted on the current
3000line to be erased.
3001In addition, only the
3002@LI{<control-D>}erase character and the
3003@QT{0<control-D>}
3004and
3005@QT{^<control-D>}
3006erase strings could erase autoindent characters.
3007(Autoindent characters include both the characters inserted automatically
3008at the beginning of an input line as well as characters inserted using the
3009@LI{<control-T>}command.)
3010This implementation permits erasure to continue past the beginning
3011of the current line, and back to where text input mode was entered.
3012In addition, autoindent characters may be erased using the standard
3013erase characters.
3014For the line and word erase characters, reaching the autoindent
3015characters forms a
3016@QQ{soft}
3017boundary, denoting the end of the current word or line erase.
3018Repeating the word or line erase key will erase the autoindent characters.
3019
3020Historically,
3021@CO{vi}
3022always used
3023@LI{<control-H>}and
3024@LI{<control-W>}as character and word erase characters, respectively, regardless of
3025the current terminal settings.
3026This implementation accepts, in addition to these two characters,
3027the current terminal characters for those operations.
3028@cindex <nul>
3029@deftypefn Input {} {<nul>}
3030
3031If the first character of the input is a
3032@LI{<nul>},
3033the previous input is replayed, as if just entered.
3034@end deftypefn
3035@cindex <control-D>
3036@deftypefn Input {} {<control-D>}
3037
3038If the previous character on the line was an autoindent character,
3039erase characters to move the cursor back to the column immediately
3040after the previous (1-based) column which is a multiple of the
3041@OP{shiftwidth}
3042edit option.
3043This may result in any number of
3044@LI{<tab>}and
3045@LI{<space>}characters preceding the cursor being changed.
3046@sp 1
3047Otherwise, if the
3048@OP{autoindent}
3049option is set and the user is entering the first character in the line,
3050@LI{<control-D>}is ignored.
3051Otherwise, a literal
3052@LI{<control-D>}character is entered.
3053@end deftypefn
3054@cindex ^<control-D>
3055@deftypefn Input {} {^<control-D>}
3056
3057If the previous character on the line was an autoindent character,
3058erase all of the autoindent characters on the line.
3059In addition, the autoindent level is reset to 0.
3060@end deftypefn
3061@cindex 0<control-D>
3062@deftypefn Input {} {0<control-D>}
3063
3064If the previous character on the line was an autoindent character,
3065erase all of the autoindent characters on the line.
3066The autoindent level is not altered.
3067@end deftypefn
3068@cindex <control-T>
3069@deftypefn Input {} {<control-T>}
3070
3071Insert sufficient
3072@LI{<tab>}and
3073@LI{<space>}characters to move the cursor forward to the column immediately
3074after the next (1-based) column which is a multiple of the
3075@OP{shiftwidth}
3076edit option.
3077This may result in any number of
3078@LI{<tab>}and
3079@LI{<space>}characters preceding the cursor being changed.
3080@sp 1
3081Historically,
3082@CO{vi}
3083did not permit the
3084@LI{<control-T>}command to be used unless the cursor was at the first column of a new
3085line or it was preceded only by autoindent characters.
3086@CO{Nvi}
3087permits it to be used at any time during insert mode.
3088@end deftypefn
3089@cindex <erase>
3090@deftypefn Input {} {<erase>}
3091
3092@cindex <control-H>
3093@deftypefnx Input {} {<control-H>}
3094Erase the last character.
3095@end deftypefn
3096@cindex "<literal-next>"
3097@deftypefn Input {} {<literal-next>}
3098
3099Quote the next character.
3100The next character will not be mapped (see the
3101@CO{map}
3102command for more information)
3103or interpreted specially.
3104A carat
3105@PQ{^}
3106character will be displayed immediately as a placeholder,
3107but will be replaced by the next character.
3108@end deftypefn
3109@cindex <escape>
3110@deftypefn Input {} {<escape>}
3111
3112If on the colon command line, and the
3113@OP{filec}
3114edit option is set, behave as described for that option.
3115Otherwise, if on the colon command line,
3116execute the command.
3117Otherwise, if not on the colon command line,
3118resolve all text input into the file, and return to command mode.
3119@end deftypefn
3120@cindex "<line erase>"
3121@deftypefn Input {} {<line erase>}
3122
3123Erase the current line.
3124@end deftypefn
3125@cindex "<control-W>"
3126@deftypefn Input {} {<control-W>}
3127
3128@cindex "<word erase>"
3129@deftypefnx Input {}  {<word erase>}
3130Erase the last word.
3131The definition of word is dependent on the
3132@OP{altwerase}
3133and
3134@OP{ttywerase}
3135options.
3136@end deftypefn
3137@cindex "<control-X>"
3138@deftypefn Input {} {<control-X>[0-9A-Fa-f]+}
3139
3140Insert a character with the specified hexadecimal value into the text.
3141The value is delimited by any non-hexadecimal character or the input
3142of the maximum number of characters that can be translated into a single
3143character value.
3144@end deftypefn
3145@cindex <interrupt>
3146@deftypefn Input {} {<interrupt>}
3147
3148Interrupt text input mode, returning to command mode.
3149If the
3150@LI{<interrupt>}character is used to interrupt inserting text into the file,
3151it is as if the
3152@LI{<escape>}character was used; all text input up to the interruption is
3153resolved into the file.
3154@end deftypefn
3155