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