1 .\" $NetBSD: vi.cmd.roff,v 1.1 2008/09/02 09:25:39 christos Exp $
4 .\" The Regents of the University of California. All rights reserved.
5 .\" Copyright (c) 1994, 1995, 1996
6 .\" Keith Bostic. All rights reserved.
8 .\" See the LICENSE file for redistribution information.
10 .\" @(#)vi.cmd.roff 8.49 (Berkeley) 8/17/96
12 .SH 1 "Vi Description"
15 takes up the entire screen to display the edited file,
16 except for the bottom line of the screen.
17 The bottom line of the screen is used to enter
21 error and informational messages.
22 If no other information is being displayed,
23 the default display can show the current cursor row and cursor column,
24 an indication of whether the file has been modified,
25 and the current mode of the editor.
30 options for more information.
32 Empty lines do not have any special representation on the screen,
33 but lines on the screen that would logically come after the end of
34 the file are displayed as a single tilde
37 To differentiate between empty lines and lines consisting of only
38 whitespace characters, use the
41 Historically, implementations of
43 have also displayed some lines as single asterisk
46 These were lines that were not correctly displayed, i.e. lines on the
47 screen that did not correspond to lines in the file, or lines that did
48 not fit on the current screen.
50 never displays lines in this fashion.
53 is a modeful editor, i.e. it has two modes,
60 first starts, it is in command mode.
61 There are several commands that change
66 character is used to resolve the text input into the file,
67 and exit back into command mode.
70 command mode, the cursor is always positioned on the last column of
71 characters which take up more than one column on the screen.
74 text insert mode, the cursor is positioned on the first column of
75 characters which take up more than one column on the screen.
77 When positioning the cursor to a new line and column,
78 the type of movement is defined by the distance to the new cursor position.
79 If the new position is close,
80 the screen is scrolled to the new location.
81 If the new position is far away,
82 the screen is repainted so that the new position is on the screen.
83 If the screen is scrolled,
84 it is moved a minimal amount,
85 and the cursor line will usually appear at the top or bottom of the screen.
86 If the screen is repainted,
87 the cursor line will appear in the center of the screen,
88 unless the cursor is sufficiently close to the beginning or end of the file
89 that this isn't possible.
92 option is set, the screen may be scrolled or repainted in a horizontal
93 direction as well as in a vertical one.
95 A major difference between the historical
99 is in the scrolling and screen oriented position commands,
110 In historical implementations of
112 these commands acted on physical (as opposed to logical, or screen)
114 For lines that were sufficiently long in relation to the size of the
115 screen, this meant that single line scroll commands might repaint the
116 entire screen, scrolling or screen positioning commands might not change
117 the screen or move the cursor at all, and some lines simply could not
118 be displayed, even though
120 would edit the file that contained them.
123 these commands act on logical, i.e. screen lines.
124 You are unlikely to notice any difference unless you are editing files
125 with lines significantly longer than a screen width.
128 keeps track of the currently
129 .QQ "most attractive"
131 Each command description (for commands that alter the current cursor
133 specifies if the cursor is set to a specific location in the line,
134 or if it is moved to the
135 .QQ "most attractive cursor position" .
136 The latter means that the cursor is moved to the cursor position that
137 is horizontally as close as possible to the current cursor position.
138 If the current line is shorter than the cursor position
140 would select, the cursor is positioned on the last character in the line.
141 (If the line is empty, the cursor is positioned on the first column
143 If a command moves the cursor to the most attractive position,
144 it does not alter the current cursor position, and a subsequent
145 movement will again attempt to move the cursor to that position.
146 Therefore, although a movement to a line shorter than the currently
147 most attractive position will cause the cursor to move to the end of
148 that line, a subsequent movement to a longer line will cause the
149 cursor to move back to the most attractive position.
153 command makes the end of each line the most attractive cursor position
154 rather than a specific column.
158 command described below notes where the cursor ends up after it is
160 This position is described in terms of characters on the line, i.e.
161 .QQ "the previous character" ,
163 .QQ "the last character in the line" .
164 This is to avoid needing to continually refer to on what part of the
165 character the cursor rests.
167 The following words have special meaning for
170 .KY "previous context"
171 .IP "previous context"
172 The position of the cursor before the command which caused the
173 last absolute movement was executed.
176 command described in the next section that is considered an
177 absolute movement is so noted.
178 In addition, specifying
182 command is considered an absolute movement.
187 command can be used as an optional trailing argument to the
195 and (depending on the
200 This command indicates the end of the region of text that's affected by
202 The motion command may be either the command character repeated (in
203 which case it means the current line) or a cursor movement command.
204 In the latter case, the region affected by the command is from the
205 starting or stopping cursor position which comes first in the file,
206 to immediately before the starting or stopping cursor position which
207 comes later in the file.
208 Commands that operate on lines instead of using beginning and ending
209 cursor positions operate on all of the lines that are wholly or
210 partially in the region.
211 In addition, some other commands become line oriented depending on
212 where in the text they are used.
213 The command descriptions below note these special cases.
215 The following commands may all be used as motion components for
223 <control-A> <control-H> <control-J> <control-M>
224 <control-N> <control-P> <space> $
238 The optional count prefix available for some of the
240 commands that take motion commands,
241 or the count prefix available for the
243 commands that are used as motion components,
244 may be included and is
246 considered part of the motion argument.
247 For example, the commands
251 are equivalent, and the region affected by the
253 command is two words of text.
255 if the optional count prefix is specified for both the
257 command and its motion component,
258 the effect is multiplicative and is considered part of the motion argument.
259 For example, the commands
263 are equivalent, and the region affected by the
265 command is four words of text.
268 A positive number used as an optional argument to most commands,
269 either to give a size or a position (for display or movement commands),
270 or as a repeat count (for commands that modify text).
271 The count argument is always optional and defaults to 1 unless otherwise
272 noted in the command description.
276 command synopsis shows both a
280 they may be presented in any order.
283 Generally, in languages where it is applicable,
285 recognizes two kinds of words.
286 First, a sequence of letters, digits and underscores,
287 delimited at both ends by:
288 characters other than letters, digits, or underscores,
289 the beginning or end of a line, and the beginning or end of the file.
290 Second, a sequence of characters other than letters, digits, underscores,
291 or whitespace characters, delimited at both ends by: a letter, digit,
292 underscore, or whitespace character,
293 the beginning or end of a line, and the beginning or end of the file.
294 For example, the characters
302 Groups of empty lines (or lines containing only whitespace characters)
303 are treated as a single word.
306 A set of non-whitespace characters preceded and followed by whitespace
307 characters or the beginning or end of the file or line.
308 For example, the characters
313 Groups of empty lines (or lines containing only whitespace characters)
314 are treated as a single bigword.
317 An area of text that begins with either the beginning of a file,
318 an empty line, or a section boundary, and continues until either
319 an empty line, section boundary, or the end of the file.
321 Groups of empty lines (or lines containing only whitespace characters)
322 are treated as a single paragraph.
324 Additional paragraph boundaries can be defined using the
329 An area of text that starts with the beginning of the file or a line
330 whose first character is an open brace
332 and continues until the next section or the end of the file.
334 Additional section boundaries can be defined using the
339 An area of text that begins with either the beginning of the file or the
340 first nonblank character following the previous sentence, paragraph, or
341 section boundary and continues until the end of the file or a period
348 followed by either an end-of-line or two whitespace characters.
349 Any number of closing parentheses
357 characters can appear between the period, exclamation point,
358 or question mark and the whitespace characters or end-of-line.
360 Groups of empty lines (or lines containing only whitespace characters)
361 are treated as a single sentence.
364 The following section describes the commands available in the command
368 In each entry below, the tag line is a usage synopsis for the command
370 In addition, the final line and column the cursor rests upon,
371 and any options which affect the command are noted.
373 .IP "[count] <control-A>"
376 times for the current word.
377 The current word begins at the first non-whitespace character on or
378 after the current cursor position,
379 and extends up to the next non-word character or the end of the line.
380 The search is literal, i.e. no characters in the word have any special
381 meaning in terms of Regular Expressions.
382 It is an error if no matching pattern is found between the starting position
383 and the end of the file.
387 command is an absolute movement.
390 command may be used as the motion component of other
392 commands, in which case any text copied into a buffer is
396 Set to the line where the word is found.
398 Set to the first character of the word.
407 .IP "[count] <control-B>"
411 Two lines of overlap are maintained, if possible,
412 by displaying the window starting at line
413 .LI "(top_line - count * window_size) + 2" ,
419 (In the case of split screens, this size is corrected to the
420 current screen size.)
421 It is an error if the movement is past the beginning of the file.
424 Set to the last line of text displayed on the screen.
426 Set to the first nonblank character of the line.
433 .IP "[count] <control-D>"
439 is not specified, scroll forward the number of lines specified by the last
449 scroll forward half the number of lines in the screen.
450 (In the case of split screens, the default scrolling distance is
451 corrected to half the current screen size.)
452 It is an error if the movement is past the end of the file.
455 Set to the current line plus the number of lines scrolled.
457 Set to the first nonblank character of the line.
462 .IP "[count] <control-E>"
465 lines, leaving the cursor on the current line and column, if possible.
466 It is an error if the movement is past the end of the file.
469 Unchanged unless the current line scrolls off the screen,
470 in which case it is set to the first line on the screen.
472 Unchanged unless the current line scrolls off the screen,
473 in which case it is set to the most attractive cursor position.
478 .IP "[count] <control-F>"
482 Two lines of overlap are maintained, if possible,
483 by displaying the window starting at line
484 .LI "top_line + count * window_size - 2" ,
490 (In the case of split screens, this size is corrected to the
491 current screen size.)
492 It is an error if the movement is past the end of the file.
495 Set to the first line on the screen.
497 Set to the first nonblank character of the current line.
505 Display the file information.
506 The information includes the current pathname, the current line,
507 the number of total lines in the file, the current line as a percentage
508 of the total lines in the file, if the file has been modified,
509 was able to be locked, if the file's name has been changed,
510 and if the edit session is read-only.
520 .IP "[count] <control-H>"
524 characters in the current line.
525 It is an error if the cursor is on the first character in the line.
531 commands may be used as the motion component of other
534 in which case any text copied into a buffer is character oriented.
540 .LI "current - count"
541 character, or, the first character in the line if
543 is greater than or equal to the number of characters in the line
549 .IP "[count] <control-J>"
551 .Ip "[count] <control-N>"
556 lines without changing the current column.
557 It is an error if the movement is past the end of the file.
564 commands may be used as the motion component of other
566 commands, in which case any text copied into a buffer is
570 Set to the current line plus
573 The most attractive cursor position.
591 .IP "[count] <control-M>"
596 lines to the first nonblank character of that line.
597 It is an error if the movement is past the end of the file.
603 commands may be used as the motion component of other
605 commands, in which case any text copied into a buffer is
609 Set to the current line plus
612 Set to the first nonblank character in the line.
617 .IP "[count] <control-P>"
622 lines, without changing the current column.
623 It is an error if the movement is past the beginning of the file.
629 commands may be used as the motion component of other
631 commands, in which case any text copied into a buffer is
635 Set to the current line minus
638 The most attractive cursor position.
644 Return to the most recent tag context.
647 command is an absolute movement.
650 Set to the context of the previous tag command.
652 Set to the context of the previous tag command.
657 .IP "[count] <control-U>"
663 is not specified, scroll backward the number of lines specified by the
674 scroll backward half the number of lines in the screen.
675 (In the case of split screens, the default scrolling distance is
676 corrected to half the current screen size.)
677 It is an error if the movement is past the beginning of the file.
680 Set to the current line minus the amount scrolled.
682 Set to the first nonblank character in the line.
688 Switch to the next lower screen in the window, or, to the first
689 screen if there are no lower screens in the window.
692 Set to the previous cursor position in the window.
694 Set to the previous cursor position in the window.
699 .IP "[count] <control-Y>"
702 lines, leaving the current line and column as is, if possible.
703 It is an error if the movement is past the beginning of the file.
706 Unchanged unless the current line scrolls off the screen,
707 in which case it is set to the last line of text displayed
710 Unchanged unless the current line scrolls off the screen,
711 in which case it is the most attractive cursor position.
717 Suspend the current editor session.
718 If the file has been modified since it was last completely written,
721 option is set, the file is written before the editor session is
723 If this write fails, the editor session is not suspended.
738 commands or cancel partial commands.
741 command is being entered (e.g.
747 the command is executed.
748 If a partial command has been entered, e.g.
751 .QT "[0-9]*[!<>cdy]" ,
752 the command is cancelled.
753 Otherwise, it is an error.
758 command is being executed, the current line is set as described for
760 Otherwise, unchanged.
764 command is being executed, the current column is set as described for
766 Otherwise, unchanged.
772 Push a tag reference onto the tag stack.
773 The tags files (see the
775 option for more information) are searched for a tag matching the
777 The current word begins at the first non-whitespace character on or
778 after the current cursor position,
779 and extends up to the next non-word character or the end of the line.
780 If a matching tag is found, the current file is discarded and the
781 file containing the tag reference is edited.
783 If the current file has been modified since it was last completely
784 written, the command will fail.
787 command is an absolute movement.
790 Set to the line containing the matching tag string.
792 Set to the start of the matching tag string.
802 Switch to the most recently edited file.
804 If the file has been modified since it was last completely written,
807 option is set, the file is written out.
808 If this write fails, the command will fail.
809 Otherwise, if the current file has been modified since it was last
810 completely written, the command will fail.
813 Set to the line the cursor was on when the file was last edited.
815 Set to the column the cursor was on when the file was last edited.
822 .IP "[count] <space>"
825 Move the cursor forward
827 characters without changing the current line.
828 It is an error if the cursor is on the last character in the line.
834 commands may be used as the motion component of other
836 commands, in which case any text copied into a buffer is
838 In addition, these commands may be used as the motion components
839 of other commands when the cursor is on the last character in the
845 Set to the current character plus the next
847 characters, or to the last character on the line if
849 is greater than the number of characters in the line after the
855 .IP "[count] ! motion shell-argument(s)<carriage-return>"
856 Replace text with results from a shell command.
857 Pass the lines specified by the
861 arguments as standard input to the program named by the
863 option, and replace those lines with the output (both
864 standard error and standard output) of that command.
866 After the motion is entered,
868 prompts for arguments to the shell command.
870 Within those arguments,
874 characters are expanded to the current and alternate pathnames,
878 character is expanded with the command text of the previous
883 (Therefore, the command
888 The special meanings of
893 can be overridden by escaping them with a backslash.
898 command has yet been executed,
899 it is an error to use an unescaped
901 character as a shell argument.
906 do shell expansion on the strings provided as arguments.
907 If any of the above expansions change the arguments the user entered,
908 the command is redisplayed at the bottom of the screen.
911 then executes the program named by the
915 flag followed by the arguments (which are bundled into a single argument).
919 command is permitted in an empty file.
921 If the file has been modified since it was last completely written,
924 command will warn you.
927 The first line of the replaced text.
929 The first column of the replaced text.
936 .IP "[count] # #|+|-"
937 Increment or decrement the number referenced by the cursor.
938 If the trailing character is a
942 the number is incremented by
944 If the trailing character is a
946 the number is decremented by
953 causes the number to be interpreted as a hexadecimal number.
956 causes the number to be interpreted as an octal number, unless a non-octal
957 digit is found as part of the number.
958 Otherwise, the number is interpreted as a decimal number, and may
964 The current number begins at the first non-blank character at or after
965 the current cursor position, and extends up to the end of the line or
966 the first character that isn't a possible character for the numeric type.
967 The format of the number (e.g. leading 0's, signs) is retained unless
968 the new value cannot be represented in the previous format.
970 Octal and hexadecimal numbers, and the result of the operation, must fit
972 .QT "unsigned long" .
973 Similarly, decimal numbers and their result must fit into a
975 It is an error to use this command when the cursor is not positioned at
982 Set to the first character in the cursor number.
988 Move the cursor to the end of a line.
991 is specified, the cursor moves down
995 It is not an error to use the
997 command when the cursor is on the last character in the line or
998 when the line is empty.
1002 command may be used as the motion component of other
1004 commands, in which case any text copied into a buffer is
1005 character oriented, unless the cursor is at, or before the first
1006 nonblank character in the line, in which case it is line oriented.
1007 It is not an error to use the
1009 command as a motion component when the cursor is on the last character
1010 in the line, although it is an error when the line is empty.
1013 Set to the current line plus
1017 Set to the last character in the line.
1023 Move to the matching character.
1024 The cursor moves to the bracket character that
1026 the bracket found at the current cursor position
1027 or which is the closest one to the right of the cursor on the line.
1028 The bracket characters are defined by the
1031 An error will be reported if none of the
1033 characters is found, or if no matching character is found.
1034 If the open and close brackes are identical (e.g.: if they are
1040 command will perform a backwards search from the original opening bracket.
1045 command was ignored.
1049 command is an absolute movement.
1052 command may be used as the motion component of other
1054 commands, in which case any text copied into a buffer is
1055 character oriented, unless the starting point of the region is at
1056 or before the first nonblank character on its line, and the ending
1057 point is at or after the last nonblank character on its line, in
1058 which case it is line oriented.
1061 Set to the line containing the matching character.
1063 Set to the matching character.
1069 Repeat the previous substitution command on the current line.
1075 command was ignored.
1080 Unchanged if the cursor was on the last character in the line,
1081 otherwise, set to the first nonblank character in the line.
1091 .KY SQUOTE<character>
1095 Return to a context marked by the character
1103 character, return to the previous context.
1106 is any other character,
1107 return to the context marked by that character (see the
1109 command for more information).
1110 If the command is the
1112 command, only the line value is restored,
1113 and the cursor is placed on the first nonblank character of that line.
1114 If the command is the
1116 command, both the line and column values are restored.
1118 It is an error if the context no longer exists because of
1120 (Contexts follow lines that are moved, or which are deleted
1127 commands are both absolute movements.
1128 They may be used as a motion component for other
1133 command, any text copied into a buffer is line oriented.
1137 any text copied into a buffer is character oriented,
1138 unless it both starts and stops at the first character in the line,
1139 in which case it is line oriented.
1140 In addition, when using the
1142 command as a motion component,
1143 commands which move backward and started at the first character in the line,
1144 or move forward and ended at the first character in the line,
1145 are corrected to the last character of the line preceding the starting and
1146 ending lines, respectively.
1149 Set to the line from the context.
1151 Set to the first nonblank character in the line, for the
1153 command, and set to the context's column for the
1167 command is an absolute movement.
1170 command may be used as the motion component of other
1173 in which case any text copied into a buffer is character oriented,
1174 unless the starting and stopping points of the region are the first
1175 character in the line,
1176 in which case it is line oriented.
1177 If it is line oriented,
1178 the starting point of the region is adjusted to be the end of the line
1179 immediately before the starting cursor position.
1182 Set to the line containing the beginning of the sentence.
1184 Set to the first nonblank character of the sentence.
1198 command is an absolute movement.
1201 command may be used as the motion component of other
1203 commands, in which case any text copied into a buffer is
1204 character oriented, unless the starting point of the region is the
1205 first character in the line, in which case it is line oriented.
1206 In the latter case, if the stopping point of the region is also
1207 the first character in the line, it is adjusted to be the end of the
1208 line immediately before it.
1211 Set to the line containing the beginning of the sentence.
1213 Set to the first nonblank character of the sentence.
1221 Reverse find character
1230 command, searching the other way in the line,
1239 command has not been performed yet.
1243 command may be used as the motion component of other
1245 commands, in which case any text copied into a buffer is
1251 Set to the searched-for character for the
1256 before the character for the
1259 and after the character for the
1267 Move to the first nonblank of the previous line,
1271 It is an error if the movement is past the beginning of the file.
1275 command may be used as the motion component of other
1277 commands, in which case any text copied into a buffer is
1281 Set to the current line minus
1284 Set to the first nonblank character in the line.
1292 command that modified text.
1293 The repeated command may be a command and motion component combination.
1296 is specified, it replaces
1298 the count specified for the repeated command, and, if applicable, for
1299 the repeated motion component.
1302 is not specified, the counts originally specified to the command being
1303 repeated are used again.
1305 As a special case, if the
1307 command is executed immediately after the
1309 command, the change log is rolled forward or backward, depending on
1315 Set as described for the repeated command.
1317 Set as described for the repeated command.
1322 .IP "/RE<carriage-return>"
1323 .Ip "/RE/ [offset]<carriage-return>"
1325 .Ip "?RE<carriage-return>"
1326 .Ip "?RE? [offset]<carriage-return>"
1331 Search forward or backward for a regular expression.
1332 The commands beginning with a slash
1334 character are forward searches, the commands beginning with a
1337 are backward searches.
1339 prompts with the leading character on the last line of the screen
1341 It then searches forward or backward in the file for the next
1342 occurrence of the string, which is interpreted as a Basic Regular
1349 commands are absolute movements.
1350 They may be used as the motion components of other
1352 commands, in which case any text copied into a buffer is
1353 character oriented, unless the search started and ended on
1354 the first column of a line, in which case it is line oriented.
1355 In addition, forward searches ending at the first character of a line,
1356 and backward searches beginning at the first character in the line,
1357 are corrected to begin or end at the last character of the previous line.
1358 (Note, forward and backward searches can occur for both
1366 If an offset from the matched line is specified (i.e. a trailing
1370 character is followed by a signed offset), the buffer will always
1371 be line oriented (e.g.
1373 will always guarantee a line orientation).
1377 command repeats the previous search, but in the reverse direction.
1380 command repeats the previous search.
1385 commands are used as motion components for the
1387 command, you will not be prompted for the text of the bang command,
1388 instead the previous bang command will be executed.
1391 .QT //<carriage-return> ,
1392 .QT /<carriage-return> ,
1393 .QT ??<carriage-return> ,
1395 .QT ?<carriage-return>
1396 search for the last search RE, in the indicated direction.
1398 Searches may be interrupted using the
1402 Multiple search patterns may be grouped together by delimiting
1403 them with semicolons and zero or more whitespace characters, e.g.
1405 searches forward for
1407 and then, from that location, backwards for
1409 When search patterns are grouped together in this manner,
1410 the search patterns are evaluated left to right with the
1411 final cursor position determined by the last search pattern.
1413 It is also permissible to append a
1415 command to the search strings, e.g.
1417 searches forward for the next occurrence of
1419 and then positions that line in the middle of screen.
1422 Set to the line in which the match occurred.
1424 Set to the first character of the matched string.
1437 Move to the first character in the current line.
1438 It is not an error to use the
1440 command when the cursor is on the first character in the line,
1444 command may be used as the motion component of other
1447 in which case it is an error if the cursor is on the first character
1449 and any text copied into a buffer is character oriented.
1454 Set to the first character in the line.
1466 command on the last line of the screen, using a colon
1469 The command is terminated by a
1470 .LI <carriage-return> ,
1474 character; all of these characters may be escaped by using a
1475 .LI "<literal-next>"
1477 The command is then executed.
1481 command writes to the screen,
1483 will prompt the user for a
1484 .LI <carriage-return>
1489 Large amounts of output from the
1491 command will be paged for the user, and the user prompted for a
1492 .LI <carriage-return>
1496 In some cases, a quit (normally a
1500 may be entered to interrupt the
1506 command finishes, and the user is prompted to resume visual mode,
1507 it is also possible to enter another
1509 character followed by another
1514 The current line is set as described for the
1518 The current column is set as described for the
1522 Affected as described for the
1528 Repeat the last character find
1531 The last character find is one of the
1544 command has not been performed yet.
1548 command may be used as the motion component of other
1550 commands, in which case any text copied into a buffer is
1556 Set to the searched-for character for the
1561 before the character for the
1564 and after the character for the
1571 .IP "[count] < motion"
1573 .Ip "[count] > motion"
1574 Shift lines left or right.
1575 Shift the number of lines in the region specified by the
1581 command) or right (for the
1583 command) by the number of columns specified by the
1586 Only whitespace characters are deleted when shifting left.
1587 Once the first character in the line no longer contains a whitespace
1588 character, the command will succeed,
1589 but the line will not be modified.
1594 Set to the first nonblank character in the line.
1602 Execute a named buffer.
1603 Execute the named buffer as
1606 The buffer may include
1608 commands, too, but they must be expressed as a
1611 If the buffer is line oriented,
1613 characters are logically appended to each line of the buffer.
1614 If the buffer is character oriented,
1616 characters are logically appended to all but the last line in the buffer.
1618 If the buffer name is
1622 then the last buffer executed shall be used.
1623 It is an error to specify
1627 if there were no previous buffer executions.
1628 The text of a buffer may contain a
1631 and it is possible to create infinite loops in this manner.
1634 character may be used to interrupt the loop.)
1637 The current line is set as described for the command(s).
1639 The current column is set as described for the command(s).
1645 Enter input mode, appending the text after the end of the line.
1648 is specified, the text is repeatedly input
1650 more times after input mode is exited.
1653 Set to the last line upon which characters were entered.
1655 Set to the last character entered.
1672 Move the cursor backward to the beginning of a bigword by repeating the
1673 following algorithm: if the current position is at the beginning of a
1674 bigword or the character at the current position cannot be part of a bigword,
1675 move to the first character of the preceding bigword.
1676 Otherwise, move to the first character of the bigword at the current position.
1677 If no preceding bigword exists on the current line, move to the first
1678 character of the last bigword on the first preceding line that contains a
1683 command may be used as the motion component of other
1685 commands, in which case any text copied into a buffer is
1689 Set to the line containing the word selected.
1691 Set to the first character of the word selected.
1696 .IP "[buffer] [count] C"
1697 Change text from the current position to the end-of-line.
1700 is specified, the input text replaces from the current position to
1701 the end-of-line, plus
1706 Set to the last line upon which characters were entered.
1708 Set to the last character entered.
1722 Delete text from the current position to the end-of-line.
1724 It is not an error to execute the
1726 command on an empty line.
1731 Set to the character before the current character, or, column 1 if
1732 the cursor was on column 1.
1741 Move the cursor forward to the end of a bigword by repeating the
1742 following algorithm: if the current position is the end of a
1743 bigword or the character at that position cannot be part of a bigword,
1744 move to the last character of the following bigword.
1745 Otherwise, move to the last character of the bigword at the current
1747 If no succeeding bigword exists on the current line,
1748 move to the last character of the first bigword on the next following
1749 line that contains a bigword.
1753 command may be used as the motion component of other
1755 commands, in which case any text copied into a buffer is
1759 Set to the line containing the word selected.
1761 Set to the last character of the word selected.
1766 .IP "[count] F <character>"
1769 times backward through the current line for
1774 command may be used as the motion component of other
1776 commands, in which case any text copied into a buffer is
1782 Set to the searched-for character.
1790 or the last line of the file if
1796 command is an absolute movement.
1799 command may be used as the motion component of other
1801 commands, in which case any text copied into a buffer is
1807 if specified, otherwise, the last line.
1809 Set to the first nonblank character in the line.
1815 Move to the screen line
1817 lines below the top of the screen.
1821 command is an absolute movement.
1824 command may be used as the motion component of other
1826 commands, in which case any text copied into a buffer is
1832 lines below the top of the screen.
1834 Set to the first nonblank character of the
1842 Enter input mode, inserting the text at the beginning of the line.
1845 is specified, the text input is repeatedly input
1850 Set to the last line upon which characters were entered.
1852 Set to the last character entered.
1863 lines are joined; a minimum of two lines are always joined,
1864 regardless of the value of
1867 If the current line ends with a whitespace character, all whitespace
1868 is stripped from the next line.
1869 Otherwise, if the next line starts with a open parenthesis
1872 Otherwise, if the current line ends with a question mark
1876 or exclamation point
1879 Otherwise, insert a single space.
1881 It is not an error to join lines past the end of the file,
1882 i.e. lines that do not exist.
1887 Set to the character after the last character of the next-to-last
1894 Move to the screen line
1896 lines above the bottom of the screen.
1900 command is an absolute movement.
1903 command may be used as the motion component of other
1905 commands, in which case any text copied into a buffer is
1911 lines above the bottom of the screen.
1913 Set to the first nonblank character of the
1921 Move to the screen line in the middle of the screen.
1925 command is an absolute movement.
1928 command may be used as the motion component of other
1930 commands, in which case any text copied into a buffer is
1937 command was ignored.
1940 Set to the line in the middle of the screen.
1942 Set to the first nonblank character of the
1950 Enter input mode, appending text in a new line above the current line.
1953 is specified, the text input is repeatedly input
1961 command was ignored.
1964 Set to the last line upon which characters were entered.
1966 Set to the last character entered.
1980 Insert text from a buffer.
1981 Text from the buffer (the unnamed buffer by default) is inserted
1982 before the current column or, if the buffer is line oriented,
1983 before the current line.
1986 Set to the lowest numbered line insert,
1987 if the buffer is line oriented, otherwise unchanged.
1989 Set to the first nonblank character of the appended text,
1990 if the buffer is line oriented, otherwise, the last character
1991 of the appended text.
1999 (or visual) mode and switch to
2012 Enter input mode, replacing the characters in the current line.
2015 is specified, the text input is repeatedly input
2019 If the end of the current line is reached, no more characters are
2020 replaced and any further characters input are appended to the line.
2023 Set to the last line upon which characters were entered.
2025 Set to the last character entered.
2038 .IP "[buffer] [count] S"
2044 Set to the last line upon which characters were entered.
2046 Set to the last character entered.
2059 .IP "[count] T <character>"
2063 through the current line for the character
2070 command may be used as the motion component of other
2072 commands, in which case any text copied into a buffer is
2078 Set to the character
2080 the searched-for character.
2086 Restore the current line to its state before the cursor last
2092 The first character in the line.
2101 Move the cursor forward to the beginning of a bigword by repeating the
2102 following algorithm: if the current position is within a bigword or the
2103 character at that position cannot be part of a bigword, move to the first
2104 character of the next bigword.
2105 If no subsequent bigword exists on the current line,
2106 move to the first character of the first bigword on the first following
2107 line that contains a bigword.
2111 command may be used as the motion component of other
2113 commands, in which case any text copied into a buffer is
2117 The line containing the word selected.
2119 The first character of the word selected.
2124 .IP "[buffer] [count] X"
2127 characters before the cursor.
2128 If the number of characters to be deleted is greater than or equal to
2129 the number of characters to the beginning of the line, all of the
2130 characters before the current cursor position, to the beginning of the
2136 Set to the current character minus
2138 or the first character if count is greater than the number of
2139 characters in the line before the cursor.
2144 .IP "[buffer] [count] Y"
2148 lines into the specified buffer.
2159 Write the file and exit
2161 The file is only written if it has been modified since the last
2162 complete write of the file to any file.
2166 command will exit the editor after writing the file,
2167 if there are no further files to edit.
2176 in a row will override this check and the editor will exit,
2177 ignoring any files that have not yet been edited.
2194 command is an absolute movement.
2197 command may be used as the motion component of other
2199 commands, in which case any text copied into a buffer is
2200 character oriented, unless the starting position is column 0,
2201 in which case it is line oriented.
2203 It is an error if the movement is past the beginning of the file.
2206 Set to the previous line that is
2208 section boundaries back,
2209 or the first line of the file if no more section boundaries exist
2210 preceding the current line.
2212 Set to the first nonblank character in the line.
2226 command is an absolute movement.
2229 command may be used as the motion component of other
2231 commands, in which case any text copied into a buffer is
2232 character oriented, unless the starting position is column 0,
2233 in which case it is line oriented.
2235 It is an error if the movement is past the end of the file.
2238 Set to the line that is
2240 section boundaries forward,
2241 or to the last line of the file if no more section
2242 boundaries exist following the current line.
2244 Set to the first nonblank character in the line.
2252 Move to first nonblank character on the current line.
2256 command may be used as the motion component of other
2258 commands, in which case any text copied into a buffer is
2264 Set to the first nonblank character of the current line.
2272 lines, to the first nonblank character.
2275 command may be used as the motion component of other
2277 commands, in which case any text copied into a buffer is
2280 It is not an error to execute the
2282 command when the cursor is on the first character in the line.
2285 The current line plus
2288 The first nonblank character in the line.
2294 Enter input mode, appending the text after the cursor.
2297 is specified, the text input is repeatedly input
2302 Set to the last line upon which characters were entered.
2304 Set to the last character entered.
2321 Move the cursor backward to the beginning of a word by repeating the
2322 following algorithm: if the current position is at the beginning of a word,
2323 move to the first character of the preceding word.
2324 Otherwise, the current position moves to the first character of the word
2325 at the current position.
2326 If no preceding word exists on the current line, move to the first
2327 character of the last word on the first preceding line that contains
2332 command may be used as the motion component of other
2334 commands, in which case any text copied into a buffer is
2338 Set to the line containing the word selected.
2340 Set to the first character of the word selected.
2345 .IP "[buffer] [count] c motion"
2346 Change the region of text specified by the
2350 If only part of a single line is affected, then the last character
2351 being changed is marked with a
2353 Otherwise, the region of text is deleted, and input mode is entered.
2356 Set to the last line upon which characters were entered.
2358 Set to the last character entered.
2371 .IP "[buffer] [count] d motion"
2372 Delete the region of text specified by the
2378 Set to the line where the region starts.
2380 Set to the first character in the line after the last character in the
2382 If no such character exists, set to the last character before the region.
2391 Move the cursor forward to the end of a word by repeating the following
2392 algorithm: if the current position is the end of a word,
2393 move to the last character of the following word.
2394 Otherwise, move to the last character of the word at the current position.
2395 If no succeeding word exists on the current line, move to the last character
2396 of the first word on the next following line that contains a word.
2400 command may be used as the motion component of other
2402 commands, in which case any text copied into a buffer is
2406 Set to the line containing the word selected.
2408 Set to the last character of the word selected.
2413 .IP "[count] f <character>"
2416 times, through the rest of the current line for
2421 command may be used as the motion component of other
2423 commands, in which case any text copied into a buffer is
2429 Set to the searched-for character.
2435 Enter input mode, inserting the text before the cursor.
2438 is specified, the text input is repeatedly input
2443 Set to the last line upon which characters were entered.
2445 Set to the last character entered.
2459 Save the current context (line and column) as
2461 The exact position is referred to by
2463 The line is referred to by
2468 was restricted to lower-case letters.
2470 permits the use of any character.
2481 Enter input mode, appending text in a new line under the current line.
2484 is specified, the text input is repeatedly input
2492 command was ignored.
2495 Set to the last line upon which characters were entered.
2497 Set to the last character entered.
2511 Append text from a buffer.
2512 Text from the buffer (the unnamed buffer by default) is appended
2513 after the current column or, if the buffer is line oriented,
2514 after the current line.
2517 Set to the first line appended, if the buffer is line oriented,
2518 otherwise unchanged.
2520 Set to the first nonblank character of the appended text if the buffer
2521 is line oriented, otherwise, the last character of the appended text.
2526 .IP "[count] r <character>"
2530 characters in the line are replaced with
2532 Replacing characters with
2534 characters results in creating new, empty lines into the file.
2540 the command is cancelled.
2543 Unchanged unless the replacement character is a
2545 in which case it is set to the current line plus
2548 Set to the last character replaced,
2549 unless the replacement character is a
2551 in which case the cursor is in column 1 of the last line inserted.
2556 .IP "[buffer] [count] s"
2559 characters in the current line starting with the current character.
2562 Set to the last line upon which characters were entered.
2564 Set to the last character entered.
2577 .IP "[count] t <character>"
2580 times, through the current line for the character immediately
2586 command may be used as the motion component of other
2588 commands, in which case any text copied into a buffer is
2594 Set to the character
2596 the searched-for character.
2602 Undo the last change made to the file.
2605 command alternates between these two states, and is its own inverse.
2606 When used after an insert that inserted text on more than one line,
2607 the lines are saved in the numeric buffers.
2611 command, when used immediately after the
2613 command, causes the change log to be rolled forward or backward,
2614 depending on the action of the
2619 Set to the position of the first line changed, if the reversal affects
2620 only one line or represents an addition or change; otherwise, the line
2621 preceding the deleted text.
2623 Set to the cursor position before the change was made.
2632 Move the cursor forward to the beginning of a word by repeating the
2633 following algorithm: if the current position is at the
2634 beginning of a word, move to the first character of the next word.
2635 If no subsequent word exists on the current line, move to the first
2636 character of the first word on the first following line that contains
2641 command may be used as the motion component of other
2643 commands, in which case any text copied into a buffer is
2647 Set to the line containing the word selected.
2649 Set to the first character of the word selected.
2654 .IP "[buffer] [count] x"
2658 The deletion is at the current character position.
2659 If the number of characters to be deleted is greater than or equal to
2660 the number of characters to the end of the line, all of the characters
2661 from the current cursor position to the end of the line are deleted.
2666 Unchanged unless the last character in the line is deleted and the cursor
2667 is not already on the first character in the line, in which case it is
2668 set to the previous character.
2673 .IP "[buffer] [count] y motion"
2676 the text region specified by the
2683 Unchanged, unless the region covers more than a single line,
2684 in which case it is set to the line where the region starts.
2686 Unchanged, unless the region covers more than a single line,
2687 in which case it is set to the character were the region starts.
2692 .IP "[count1] z [count2] type"
2693 Redraw the screen with a window
2695 lines long, with line
2697 placed as specified by the
2702 is not specified, it defaults to the current line.
2705 is not specified, it defaults to the current window size.
2709 characters may be used:
2714 is specified, place the line
2716 at the top of the screen.
2717 Otherwise, display the screen after the current screen, similarly to the
2720 .SP <carriage-return>
2723 at the top of the screen.
2727 in the center of the screen.
2731 at the bottom of the screen.
2735 is specified, place the line that is at the top of the screen
2738 is at the bottom of the screen, at the bottom of the screen,
2739 i.e. display the screen before the screen before
2741 Otherwise, display the screen before the current screen, similarly to the
2751 is not specified and the
2753 character was either
2757 in which case it is set to the line before the first line on the
2758 previous screen or the line after the last line on the previous
2759 screen, respectively.
2761 Set to the first nonblank character in the line.
2773 command is an absolute movement.
2776 command may be used as the motion component of other
2778 commands, in which case any text copied into a buffer is
2779 character oriented, unless the starting character is the first
2780 character on its line, in which case it is line oriented.
2783 Set to the line containing the beginning of the previous paragraph.
2785 Set to the first nonblank character in the line.
2795 position on the current line.
2799 command may be used as the motion component of other
2801 commands, in which case any text copied into a buffer is
2803 It is an error to use the
2805 command as a motion component and for the cursor not to move.
2810 Set to the character occupying the column position identified by
2812 if the position exists in the line.
2813 If the column length of the current line is less than
2815 the cursor is moved to the last character in the line.
2827 command is an absolute movement.
2830 command may be used as the motion component of other
2832 commands, in which case any text copied into a buffer is
2833 character oriented, unless the starting character is at or
2834 before any nonblank characters in its line,
2835 in which case it is line oriented.
2838 Set to the line containing the beginning of the next paragraph.
2840 Set to the first nonblank character in the line.
2848 Reverse the case of the next
2851 This is the historic semantic for the
2853 command and it is only in effect if the
2857 Lowercase alphabetic characters are changed to uppercase,
2858 and uppercase characters are changed to lowercase.
2859 No other characters are affected.
2863 command did not take an associated count, nor did it move past the
2864 end of the current line.
2865 As it had no associated motion it was difficult to change the case
2866 of large blocks of text.
2869 if the cursor is on the last character of a line, and there are
2870 more lines in the file, the cursor moves to the next line.
2872 It is not an error to specify a count larger than the number of
2873 characters between the cursor and the end of the file.
2876 Set to the line of the character after
2878 characters, or, end of file.
2880 Set to the character after
2882 characters, or, end-of-file.
2889 .IP "[count] ~ motion"
2890 Reverse the case of the characters in a text region specified by the
2894 Only in effect if the
2898 Lowercase characters are changed to uppercase,
2899 and uppercase characters are changed to lowercase.
2900 No other characters are affected.
2903 Set to the line of the character after the last character in the region.
2905 Set to the character after the last character in the region.
2913 Interrupt the current operation.
2914 Many of the potentially long-running
2916 commands may be interrupted using the terminal interrupt character.
2917 These operations include searches, file reading and writing, filter
2918 operations and map character expansion.
2919 Interrupts are also enabled when running commands outside of
2924 character is used to interrupt while entering an
2926 command, the command is aborted, the cursor returns to its previous
2929 remains in command mode.
2933 character is used to interrupt any
2934 operation, any changes made before the interrupt are left in place.
2937 Dependent on the operation being interrupted.
2939 Dependent on the operation being interrupted.
2942 .SH 1 "Vi Text Input Commands"
2944 The following section describes the commands available in the text
2951 implementations only permitted the characters inserted on the current
2953 In addition, only the
2955 erase character and the
2959 erase strings could erase autoindent characters.
2960 (Autoindent characters include both the characters inserted automatically
2961 at the beginning of an input line as well as characters inserted using the
2964 This implementation permits erasure to continue past the beginning
2965 of the current line, and back to where text input mode was entered.
2966 In addition, autoindent characters may be erased using the standard
2968 For the line and word erase characters, reaching the autoindent
2971 boundary, denoting the end of the current word or line erase.
2972 Repeating the word or line erase key will erase the autoindent characters.
2980 as character and word erase characters, respectively, regardless of
2981 the current terminal settings.
2982 This implementation accepts, in addition to these two characters,
2983 the current terminal characters for those operations.
2986 If the first character of the input is a
2988 the previous input is replayed, as if just entered.
2991 If the previous character on the line was an autoindent character,
2992 erase characters to move the cursor back to the column immediately
2993 after the previous (1-based) column which is a multiple of the
2996 This may result in any number of
3000 characters preceding the cursor being changed.
3004 option is set and the user is entering the first character in the line,
3007 Otherwise, a literal
3009 character is entered.
3012 If the previous character on the line was an autoindent character,
3013 erase all of the autoindent characters on the line.
3014 In addition, the autoindent level is reset to 0.
3017 If the previous character on the line was an autoindent character,
3018 erase all of the autoindent characters on the line.
3019 The autoindent level is not altered.
3026 characters to move the cursor forward to the column immediately
3027 after the next (1-based) column which is a multiple of the
3030 This may result in any number of
3034 characters preceding the cursor being changed.
3040 command to be used unless the cursor was at the first column of a new
3041 line or it was preceded only by autoindent characters.
3043 permits it to be used at any time during insert mode.
3048 Erase the last character.
3049 .KY "<literal-next>"
3050 .IP "<literal-next>"
3051 Quote the next character.
3052 The next character will not be mapped (see the
3054 command for more information)
3055 or interpreted specially.
3058 character will be displayed immediately as a placeholder,
3059 but will be replaced by the next character.
3062 If on the colon command line, and the
3064 edit option is set, behave as described for that option.
3065 Otherwise, if on the colon command line,
3066 execute the command.
3067 Otherwise, if not on the colon command line,
3068 resolve all text input into the file, and return to command mode.
3071 Erase the current line.
3076 Erase the last word.
3077 The definition of word is dependent on the
3083 .IP "<control-X>[0-9A-Fa-f]+"
3084 Insert a character with the specified hexadecimal value into the text.
3085 The value is delimited by any non-hexadecimal character or the input
3086 of the maximum number of characters that can be translated into a single
3090 Interrupt text input mode, returning to command mode.
3093 character is used to interrupt inserting text into the file,
3096 character was used; all text input up to the interruption is
3097 resolved into the file.