2 .\" The Regents of the University of California. All rights reserved.
3 .\" Copyright (c) 1994, 1995, 1996
4 .\" Keith Bostic. All rights reserved.
6 .\" This document may not be republished without written permission from
9 .\" See the LICENSE file for redistribution information.
11 .\" @(#)vi.ref 8.88 (Berkeley) 10/19/96
20 Vi/Ex Reference Manual
26 Computer Science Division
27 Department of Electrical Engineering and Computer Science
28 University of California, Berkeley
29 Berkeley, California 94720
38 This document is the reference guide for the 4.4BSD
41 which are implementations of the historic Berkeley
51 Copyright (c) 1991, 1992, 1993, 1994
53 The Regents of the University of California. All Rights Reserved.
55 Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996
57 Keith Bostic. All Rights Reserved.
60 The vi program is freely redistributable. You are welcome to copy,
61 modify and share it with others under the conditions listed in the
62 LICENSE file. If any company (not individual!) finds vi sufficiently
63 useful that you would have purchased it, or if any company wishes to
64 redistribute it, contributions to the authors would be appreciated.
72 Bruce Englar encouraged the early development of the historic
75 Peter Kessler helped bring sanity to version 2's command layout.
76 Bill Joy wrote versions 1 and 2.0 through 2.7,
77 and created the framework that users see in the present editor.
78 Mark Horton added macros and other features and made
80 work on a large number of terminals and Unix systems.
83 is originally derived from software contributed to the University of
84 California, Berkeley by Steve Kirkendall, the author of the
89 IEEE Standard Portable Operating System Interface for Computer
90 Environments (POSIX) 1003.2 style Regular Expression support was
91 done by Henry Spencer.
93 The curses library was originally done by Ken Arnold.
94 Scrolling and reworking for
96 was done by Elan Amir.
98 George Neville-Neil added the Tcl interpreter,
99 and Sven Verdoolaege added the Perl interpreter.
101 Rob Mayoff added Cscope support.
103 The Institute of Electrical and Electronics Engineers has
104 given us permission to reprint portions of their documentation.
105 Portions of this document are reprinted and reproduced from
106 IEEE Std 1003.2-1992, IEEE Standard Portable Operating
107 System Interface for Computer Environments (POSIX),
108 copyright 1992 by the Institute of Electrical and Electronics
111 The financial support of UUNET Communications Services is gratefully
115 .oh 'Vi/Ex Reference''USD:13-%'
116 .eh 'USD:13-%''Vi/Ex Reference'
121 is a screen oriented text editor.
123 is a line-oriented text editor.
127 are different interfaces to the same program,
128 and it is possible to switch back and forth during an edit session.
130 is the equivalent of using the
132 (read-only) option of
135 This reference manual is the one provided with the
141 are intended as bug-for-bug compatible replacements for the original
142 Fourth Berkeley Software Distribution (4BSD)
145 This reference manual is accompanied by a traditional-style manual page.
146 That manual page describes the functionality found in
148 in far less detail than the description here.
149 In addition, it describes the system interface to
151 e.g. command line options, session recovery, signals,
152 environmental variables, and similar things.
154 This reference is intended for users already familiar with
156 Anyone else should almost certainly read a good tutorial on the
158 If you are in an unfamiliar environment,
159 and you absolutely have to get work done immediately,
160 see the section entitled
163 It is probably enough to get you started.
165 There are a few features in
167 that are not found in historic versions of
169 Some of the more interesting of those features are briefly described
170 in the next section, entitled
171 .QB "Additional Features" .
172 For the rest of this document,
174 is used only when it is necessary to distinguish it from the historic
178 Future versions of this software will be periodically made available
179 by anonymous ftp, and can be retrieved from
180 .LI ftp.cs.berkeley.edu ,
183 .SH 1 "Additional Features in Nex/Nvi"
185 There are a few features in
187 that are not found in historic versions of
189 Some of the more interesting of these are as follows:
190 .IP "8-bit clean data, large lines, files"
192 will edit any format file.
193 Line lengths are limited by available memory,
194 and file sizes are limited by available disk space.
197 text input mode command
199 can insert any possible character value into the text.
200 .IP "Background and foreground screens"
203 command backgrounds the current screen, and the
205 command foregrounds backgrounded screens.
208 command can be used to list the background screens.
209 .IP "Command Editing"
210 You can enter a normal editing window on the collected commands that
211 you've entered on the
214 and then modify and/or execute the commands.
217 edit option for more information.
221 command can be used to display the current buffers, the backgrounded
222 screens, and the tags stack.
223 .IP "Extended Regular Expressions"
226 option causes Regular Expressions to be interpreted as as Extended
227 Regular Expressions, (i.e. \fIegrep\fP(1) style Regular Expressions).
228 .IP "File Name Completion"
229 It is possible to do file name completion and file name displays when
230 entering commands on the
235 option for more information.
237 Changes made during an edit session may be rolled backward and forward.
240 command immediately after a
242 command continues either forward or backward depending on whether the
244 command was an undo or a redo.
245 .IP "Left-right scrolling"
250 to do left-right screen scrolling, instead of the traditional
253 .IP "Message Catalogs"
254 It is possible to display informational and error messages in different
255 languages by providing a catalog of messages.
260 for more information.
261 .IP "Incrementing numbers"
264 command increments or decrements the number referenced by the cursor.
268 command edits the previous file from the argument list.
269 .IP "Scripting languages"
275 commands execute Perl and Tcl/Tk commands, respectively,
276 on lines from the edit buffer.
278 .QB "Scripting Languages"
279 section and the specific commands for more information.
280 .\".IP "Shell screens"
282 .\".CO ":sc[ript] [file ...]"
283 .\"command runs a shell in the screen.
284 .\"Editing is unchanged, with the exception that a \fC<carriage-return>\fP
285 .\"enters the current line (stripped of any prompt) as input to the
298 mode) commands divide the screen into multiple editing regions and
299 then perform their normal function in a new screen area.
302 command rotates between the foreground screens.
305 command can be used to grow or shrink a particular screen.
307 Tags are now maintained in a stack.
310 command returns to the previous tag location.
313 command returns to the most recent tag location by default, or,
314 optionally to a specific tag number in the tag stack,
315 or the most recent tag from a specified file.
318 command can be used to list the tags stack.
321 command returns to the top of the tag stack.
322 .IP "Usage information"
327 commands provide usage information for all of the
331 commands by default, or, optionally, for a specific command or key.
335 command searches for the word referenced by the cursor.
336 .SH 1 "Startup Information"
339 interprets one of two possible environmental variables and reads up to
340 three of five possible files during startup.
341 The variables and files are expected to contain
346 In addition, they are interpreted
348 the file to be edited is read, and therefore many
350 commands may not be used.
351 Generally, any command that requires output to the screen or that
352 needs a file upon which to operate, will cause an error if included
353 in a startup file or environmental variable.
357 command set supported by
359 is a superset of the command set supported by historical implementations of
362 can use the startup files created for the historical implementations,
363 but the converse may not be true.
367 (the historic \- option)
368 is specified, or if standard input is redirected from a file,
369 all environmental variables and startup files are ignored.
371 Otherwise, startup files and environmental variables are handled
372 in the following order:
377 as long as it is owned by root or the effective user ID of the user.
379 The environmental variable
385 is not set) is interpreted.
393 environmental variable is set, the file
399 does not exist) is read,
400 as long as the effective user ID of the user is root or is the same as
401 the owner of the file.
403 When the $HOME directory is being used for both
405 and an historic implementation of
407 a possible solution is to put
409 specific commands in the
412 .CO ":source $HOME/.exrc"
413 command to read in the commands common to both implementations.
417 option was turned on by one of the previous startup information
424 does not exist) is read, as long as the effective user ID of the user
425 is the same as the owner of the file.
427 No startup file is read if it is writable by anyone other than its owner.
429 It is not an error for any of the startup environmental variables or files
432 Once all environmental variables are interpreted,
433 and all startup files are read,
434 the first file to be edited is read in (or a temporary file is created).
435 Then, any commands specified using the
437 option are executed, in the context of that file.
440 There is no recovery program for
445 Recovery files are created readable and writable by the owner only.
446 Users may recover any file which they can read,
447 and the superuser may recover any edit session.
449 Edit sessions are backed by files in the directory named by the
451 option (the directory
452 .LI /var/tmp/vi.recover
453 by default), and are named
457 is a number related to the process ID.
458 When a file is first modified,
459 a second recovery file containing an email message for the user is created,
464 is associated with the process ID.
465 Both files are removed at the end of a normal edit session,
466 but will remain if the edit session is abnormally terminated
474 option may be set in either the user's or system's startup information,
475 changing the recovery directory.
476 (Note, however, that if a memory based file system is used as the backup
477 directory, each system reboot will delete all of the recovery files!
478 The same caution applies to directories such as
480 which are cleared of their contents by a system reboot, or
482 which is periodically cleared of old files on many systems.)
484 The recovery directory should be owned by root, or at least by a pseudo-user.
485 In addition, if directory
487 semantics are available, the directory should have the sticky-bit
488 set so that files may only be removed by their owners.
489 The recovery directory must be read, write, and executable by any user,
492 If the recovery directory does not exist,
494 will attempt to create it.
495 This can result in the recovery directory being owned by a normal user,
496 which means that that user will be able to remove other user's recovery
498 This is annoying, but is not a security issue as the user cannot
499 otherwise access or modify the files.
501 The recovery file has all of the necessary information in it to enable the
502 user to recover the edit session.
503 In addition, it has all of the necessary email headers for
505 When the system is rebooted, all of the files in
506 .LI /var/tmp/vi.recover
509 should be sent to their owners, by email, using the
513 (or a similar mechanism in other mailers).
516 receives a hangup (SIGHUP) signal, or the user executes the
521 will automatically email the recovery information to the user.
523 If your system does not have the
525 utility (or a mailer program which supports its interface)
527 .LI nvi/common/recover.c
528 will have to be modified to use your local mail delivery programs.
531 is changed to use another mailer,
532 it is important to remember that the owner of the file given to
535 user, so nothing in the file should be trusted as it may have been
536 modified in an effort to compromise the system.
538 Finally, the owner execute bit is set on backup files when they are
539 created, and unset when they are first modified, e.g. backup files
540 that have no associated email recovery file will have this bit set.
541 (There is also a small window where empty files can be created and
542 not yet have this bit set.
543 This is due to the method in which the files are created.)
544 Such files should be deleted when the system reboots.
546 A simple way to do this cleanup is to run the Bourne shell script
550 (or other system startup) file.
551 The script should work with the historic Bourne shell,
552 a POSIX 1003.2 shell or the Korn shell.
555 script is installed as part of the
557 installation process.
559 Consult the manual page for details on recovering preserved or
560 aborted editing sessions.
561 .SH 1 "Sizing the Screen"
563 The size of the screen can be set in a number of ways.
565 takes the following steps until values are obtained for both the
566 number of rows and number of columns in the screen.
568 If the environmental variable
571 it is used to specify the number of rows in the screen.
573 If the environmental variable
576 it is used to specify the number of columns in the screen.
580 is attempted on the standard error file descriptor.
582 The termcap entry (or terminfo entry on System V machines)
589 The number of rows is set to 24, and the number of columns is set to 80.
591 If a window change size signal (SIGWINCH) is received,
592 the new window size is retrieved using the TIOCGWINSZ
594 call, and all other information is ignored.
595 .SH 1 "Character Display"
601 printable characters as defined by
603 are displayed using the local character set.
605 Non-printable characters, for which
607 returns true, and which are less than octal \e040,
608 are displayed as the string
612 is the character that is the original character's value offset from the
615 For example, the octal character \e001 is displayed as
619 returns true for the octal character \e177,
620 it is displayed as the string
622 All other characters are displayed as either hexadecimal values,
624 .QT "0x<high-halfbyte> ... 0x<low-halfbyte>" ,
625 or as octal values, in the form
626 .QT "\e<high-one-or-two-bits> ... \e<low-three-bits>" .
627 The display of unknown characters is based on the value of the
633 command mode, the cursor is always positioned on the last column of
634 characters which take up more than one column on the screen.
637 text input mode, the cursor is positioned on the first column of
638 characters which take up more than one column on the screen.
639 .SH 1 "Multiple Screens"
642 supports multiple screens by dividing the window into regions.
643 It also supports stacks of screens by permitting the user to change
644 the set of screens that are currently displayed.
658 commands divide the current screen into two regions of approximately
659 equal size and then perform their usual action in a new screen area.
660 If the cursor is in the lower half of the screen, the screen will split
661 up, i.e. the new screen will be above the old one.
662 If the cursor is in the upper half of the screen, the new screen will be
665 When more than one screen is editing a file, changes in any screen are
666 reflected in all other screens editing the same file.
667 Exiting a screen without saving any changes (or explicitly discarding
668 them) is permitted until the last screen editing the file is exited,
669 at which time the changes must be saved or discarded.
673 command permits resizing of individual screens.
674 Screens may be grown, shrunk or set to an absolute number of rows.
678 command is used to switch between screens.
681 moves to the next lower screen in the window, or to the first screen
682 in the window if there are no lower screens.
689 The screen disappears from the window,
690 and the rows it occupied are taken over by a neighboring screen.
691 It is an error to attempt to background the only screen in the window.
694 .CO "display screens"
695 command displays the names of the files associated with the current
696 backgrounded screens in the window.
700 command moves the specified screen from the list of backgrounded screens
702 If no file argument is specified, the first screen on the list is
705 foregrounding consists of backgrounding the current screen,
706 and replacing its space in the window with the foregrounded screen.
708 Capitalizing the first letter of the command, i.e.
710 will foreground the backgrounded screen in a new screen instead of
711 swapping it with the current screen.
713 If the last foregrounded screen in the window is exited,
714 and there are backgrounded screens,
715 the first screen on the list of backgrounded screens takes over the window.
716 .SH 1 "Tags, Tag Stacks, and Cscope"
719 supports the historic
727 These commands change the current file context to a new location,
728 based on information found in the
731 If you are unfamiliar with these commands,
732 you should review their description in the
736 commands section of this manual.
737 For additional information on tags files,
738 see the discussion of the
740 edit option and the system
746 supports the notion of
753 command returns the user to the previous context, i.e.,
754 the last place from which a
759 These three commands provide the basic functionality which allows you
762 to review source code in a structured manner.
765 also provides two other basic
767 commands for tag support:
773 command is identical to the
776 with the additional functionality that you may specify that modifications
777 to the current file are to be discarded.
778 This cannot be done using the
783 command discards all of the contexts that have been pushed onto the tag
784 stack, returning to the context from which the first
792 tags file format supports only a single location per tag,
793 normally the function declaration or structure or string definition.
794 More sophisticated source code tools often provide multiple locations
796 a list of the places from which a function is called or a string
798 An example of this functionality is the System V source code tool,
802 creates a database of information on source code files,
803 and supports a query language for that information as described in the
807 contains an interface to the
809 query language which permits you to query
811 and then sequentially step through the locations in the sources files which
816 commands which support this ability to step through multiple locations.
825 command moves to the next location for the current tag.
828 command moves to the previous location for the current tag.
833 command discussion in the
835 commands section of this manual for more information.)
836 At any time during this sequential walk,
842 commands to move to a new tag context, and then use the
846 commands to return and continue stepping through the locations for this
848 This is similar to the previous model of a simple tag stack,
849 except that each entry in the tag stack may have more than one file context
852 Although there is no widely distributed version of
854 that creates tags files with multiple locations per tag,
856 has been written to understand the obvious extension to the historic
857 tags file format, i.e., more than a single line in the tags file with
858 the same initial tag name.
859 If you wish to extend your
861 implementation or other tool with which you build tags files,
862 this extension should be simple and will require no changes to
869 interface is based on the new
873 which has five subcommands:
882 itself has eight subcommands:
893 .IP "cs[cope] a[dd] file"
896 command attaches to the specified
899 The file name is expanded using the standard filename expansions.
902 is a directory, the file
904 in that directory is used as the database.
908 attaches to a new database,
911 queries will be asked of that database.
912 The result of any single query is the collection of response to the query
913 from all of the attached databases.
917 environmental variable is set when
920 it is expected to be a <colon> or <blank>-separated list of
922 databases or directories containing
924 databases, to which the user wishes to attach.
925 .IP ":cs[cope] f[ind] c|d|e|f|g|i|s|t buffer|pattern"
936 databases for the pattern.
937 If the pattern is a double-quote character followed by a valid buffer
939 .LI """<character>" ),
940 then the contents of the named buffer are used as the pattern.
941 Otherwise, the pattern is a Regular Expression.
945 command pushes the current location onto the tags stack,
946 and switches to the first location resulting from the query,
947 if the query returned at least one result.
949 File names returned by the
951 query, if not absolute paths, are searched for relative to the directory
955 In addition, if the file
957 appears in the same directory as the
960 it is expected to contain a colon-separated list of directory names
961 where files referenced by its associated
963 database may be found.
967 subcommand is one of the following:
970 Find callers of the name.
972 Find all function calls made from name.
976 Find files with name as substring.
978 Find definition of name.
980 Find files #including name.
982 Find all uses of name.
984 Find assignments to name.
986 .IP ":cs[cope] h[elp] [command]"
990 or optionally list usage help for any single
993 .IP ":display c[onnections]"
998 is currently connected.
999 .IP ":cs[cope] k[ill] #"
1000 Disconnect from a specific
1003 The connection number is the one displayed by the
1005 .CO "display connections"
1007 .IP ":cs[cope] r[eset]"
1008 Disconnect from all attached
1012 Cscope is not freely redistributable software,
1013 but is fairly inexpensive and easily available.
1014 To purchase a copy of
1016 see http://www.att.com/ssg/products/toolchest.html.
1017 .SH 1 "Regular Expressions and Replacement Strings"
1019 Regular expressions are used in line addresses,
1020 as the first part of the
1026 commands, and in search patterns.
1028 The regular expressions supported by
1030 are, by default, the Basic Regular Expressions (BRE's) described in the
1031 IEEE POSIX Standard 1003.2.
1034 option causes all regular expressions to be interpreted as the Extended
1035 Regular Expressions (ERE's) described by the same standard.
1038 for more information.)
1039 Generally speaking, BRE's are the Regular Expressions found in
1043 and ERE's are the Regular Expressions found in
1046 The following is not intended to provide a description of Regular
1048 The information here only describes strings and characters which
1049 have special meanings in the
1052 or options which change the meanings of characters that normally
1053 have special meanings in RE's.
1059 is equivalent to the last RE used.
1063 matches the beginning of a word.
1067 matches the end of a word.
1071 matches the replacement part of the last
1079 set, the only characters with special meanings are a
1081 character at the beginning of an RE, a
1083 character at the end of an RE, and the escaping character
1091 are treated as ordinary characters unless preceded by a
1095 they regain their special meaning.
1097 Replacement strings are the second part of a
1109 set) in the replacement string stands for the text matched by the RE
1110 that is being replaced.
1119 set) stands for the replacement part of the previous
1122 It is only valid after a
1124 command has been performed.
1130 is an integer value from 1 to 9, stands for the text matched by
1131 the portion of the RE enclosed in the
1133 set of escaped parentheses, e.g.
1138 .QT "s/abc\e(.*\e)def/\e1/"
1143 from the matched pattern.
1151 can be used to modify the case of elements in the replacement string.
1154 causes the next character to be converted to lowercase;
1157 behaves similarly, but converts to uppercase
1166 causes characters up to the end of the string or the next occurrence
1171 to be converted to lowercase;
1174 behaves similarly, but converts to uppercase.
1176 If the entire replacement pattern is
1178 then the last replacement pattern is used again.
1184 into the replacement string will cause
1185 the matched line to be split into two lines at that point.
1189 .SH 1 "Scripting Languages"
1193 editor currently supports two scripting languages, Tcl/Tk and Perl.
1194 (Note that Perl4 isn't sufficient, and that the Perl5 used must be
1195 version 5.002 or later.
1198 section for more information.
1200 The scripting language interface is still being worked on,
1201 therefore the following information is probably incomplete,
1202 probably wrong in cases, and likely to change.
1207 source directories for more information.
1208 As a quick reference, the following function calls are provided for
1209 both the Perl and Tcl interfaces.
1210 The Perl interface uses a slightly different naming convention,
1211 e.g. ``viFindScreen'' is named ``VI::FindScreen''.
1212 .IP "viFindScreen file"
1214 .LI "screenId" associated with
1216 .IP "viAppendLine screenId lineNumber text"
1219 as a new line after line number
1223 .IP "viDelLine screenId lineNum"
1228 .IP "viGetLine screenId lineNumber"
1233 .IP "viInsertLine screenId lineNumber text"
1236 as a new line before line number
1240 .IP "viLastLine screenId"
1241 Return the line number of the last line in the screen
1243 .IP "viSetLine screenId lineNumber text"
1248 to match the specified
1250 .IP "viGetMark screenId mark"
1251 Return the current line and column for the specified
1255 .IP "viSetMark screenId mark line column"
1264 .IP "viGetCursor screenId"
1265 Return the current line and column for the cursor in the screen
1267 .IP "viSetCursor screenId line column"
1268 Set the cursor in the screen
1274 .IP "viMsg screenId text"
1275 Display the specified
1277 as a vi message in the screen
1279 .IP "viNewScreen screenId [file]"
1280 Create a new screen.
1281 .IP "viEndScreen screenId"
1284 .IP "viSwitchScreen screenId screenId"
1285 Switch from the screen
1289 .IP "viMapKey screenId key tclproc"
1294 to the Tcl procedure
1296 .IP "viUnmMapKey screenId key"
1301 .IP "viGetOpt screenId option"
1302 Return the value of the specified
1306 .IP "viSetOpt screenId command"
1307 Set one or more options in the screen
1309 .SH 1 "General Editor Description"
1316 the text of a file is read (or a temporary file is created),
1317 and then all editing changes happen within the context of the
1319 .i "No changes affect the actual file until the file is written out" ,
1320 either using a write command or another command which is affected by the
1324 All files are locked (using the
1328 interfaces) during the edit session,
1329 to avoid inadvertently making modifications to multiple copies of the file.
1330 If a lock cannot be obtained for a file because it is locked by another
1331 process, the edit session is read-only (as if the
1335 flag had been specified).
1336 If a lock cannot be obtained for other reasons, the edit session will
1337 continue, but the file status information
1340 command) will reflect this fact.
1346 are modeful editors, i.e. they have two modes,
1351 The former is intended to permit you to enter commands which modifies
1352 already existing text.
1353 The latter is intended to permit you to enter new text.
1356 first starts running, it is in command mode, and usually displays a prompt
1359 option for more information).
1360 The prompt is a single colon
1363 There are three commands that switch
1365 into text input mode:
1370 Once in input mode, entering a line containing only a single period
1372 ends text input mode and returns to command mode,
1373 where the prompt is redisplayed.
1377 first starts running, it is in command mode as well.
1378 There are eleven commands that switch
1380 into text input mode:
1393 Once in input mode, entering an
1395 character ends text input mode and returns to command mode.
1398 present three different interfaces to editing a file.
1400 presents a line oriented interface.
1402 presents a full screen display oriented interface,
1405 In addition, there is a third mode,
1407 which is line oriented,
1408 but supports cursor movement and editing within the displayed line,
1409 similarly to visual mode.
1410 Open mode is not yet implemented in
1413 The following words have special meanings in both the
1417 command descriptions:
1420 The interrupt character is used to interrupt the current operation.
1423 whatever character is set for the current terminal is used.
1424 .KY "<literal-next>"
1425 .IP "<literal-next>"
1426 The literal next character is used to escape the subsequent character
1427 from any special meaning.
1428 This character is always
1430 If the terminal is not set up to do XON/XOFF flow control,
1433 is used to mean literal next as well.
1434 .KY "current pathname"
1435 .IP "current pathname"
1436 The pathname of the file currently being edited by vi.
1437 When the percent character
1439 appears in a file name entered as part of an
1441 command argument, it is replaced by the current pathname.
1444 character can be escaped by preceding it with a backslash.)
1445 .KY "alternate pathname"
1446 .IP "alternate pathname"
1447 The name of the last file name mentioned in an
1450 the previous current pathname if the last file mentioned
1451 becomes the current file.
1452 When the hash mark character
1454 appears in a file name entered as part of an
1456 command argument, it is replaced by the alternate pathname.
1459 character can be escaped by preceding it with a backslash.)
1462 One of a number of named areas for saving copies of text.
1463 Commands that change or delete text can save the changed or deleted
1464 text into a specific buffer, for later use, if the command allows
1468 command cannot save the changed text in a named buffer).
1469 Buffers are named with a single character, preceded by a double quote,
1475 without the double quote, e.g.
1479 (The double quote isn't necessary for
1481 because buffers names are denoted by their position in the command line.)
1482 Historic implementations of
1486 to the alphanumeric characters;
1488 permits the use of any character without another meaning in the position
1489 where a buffer name is expected.
1491 Buffers named by uppercase characters are the same as buffers
1492 named by lowercase characters, e.g. the buffer named by the
1495 is the same as the buffer named by the character
1497 with the exception that, if the buffer contents are being changed (as
1498 with a text deletion or
1501 command), the text is
1503 to the buffer, instead of replacing the current contents.
1505 The buffers named by the numeric characters (in English,
1510 If a region of text including characters from more than one line,
1511 or a single line of text specified by using a line-oriented motion,
1512 is changed or deleted in the file using the
1517 commands, a copy of the text is placed into the numeric buffer
1519 regardless of the user specifying another buffer in which to save it.
1520 In addition, there are a few commands which, when used as a
1529 copy the specified region of text into the numeric buffers regardless
1530 of the region including characters from more than one line.
1543 Before this copy is done, the previous contents of buffer
1545 are moved into buffer
1551 The contents of buffer
1556 text may be explicitly stored into the numeric buffers.
1557 In this case, the buffer rotation described above occurs before the
1558 replacement of the buffer's contents.
1559 The numeric buffers are only available in
1564 and are not accessible by
1566 in any way, although changed and deleted text is still stored there
1573 command synopsis shows both a
1577 they may be presented in any order.
1579 Finally, all buffers are either
1586 commands which store text into buffers are line oriented.
1589 commands which store text into buffers are line oriented,
1590 and some are character oriented; the description for each applicable
1592 command notes whether text copied into buffers using the command
1593 is line or character oriented.
1597 .CO "display buffers"
1598 displays the current orientation for each buffer.
1599 Generally, the only importance attached to this orientation is that
1600 if the buffer is subsequently inserted into the text, line oriented
1601 buffers create new lines for each of the lines they contain, and
1602 character oriented buffers create new lines for any lines
1604 than the first and last lines they contain.
1605 The first and last lines are inserted into the text at the current
1606 cursor position, becoming part of the current line.
1607 If there is more than one line in the buffer, however, the current
1608 line itself will be split.
1609 .KY "unnamed buffer"
1610 .IP "unnamed buffer"
1611 The unnamed buffer is a text storage area which is used by commands
1612 that use or operate on a buffer when no buffer is specified by the user.
1613 If the command stores text into a buffer,
1614 the text is stored into the unnamed buffer even if a buffer is also
1615 specified by the user.
1616 It is not possible to append text to the unnamed buffer.
1617 If text is appended to a named buffer,
1618 the named buffer contains both the old and new text,
1619 while the unnamed buffer contains only the new text.
1620 There is no way to explicitly reference the unnamed buffer.
1622 Historically, the contents of the unnamed buffer were discarded by many
1623 different commands, even ones that didn't store text into it.
1625 never discards the contents of the unnamed buffer until new text
1629 The characters <tab> and <space>.
1630 .KY "<carriage-return>"
1631 .IP "<carriage-return>"
1632 The character represented by an ASCII
1634 This character is almost always treated identically to a
1636 character, but differs in that it can be escaped into the file text or
1640 The character represented by an ASCII
1642 This character is almost always treated identically to a
1644 character, but differs in that it cannot be escaped into the file text or
1646 .oh 'Vi/Ex Reference (Vi Commands)''USD:13-%'
1647 .eh 'USD:13-%''Vi/Ex Reference (Vi Commands)'
1649 .oh 'Vi/Ex Reference''USD:13-%'
1650 .eh 'USD:13-%''Vi/Ex Reference'
1651 .SH 1 "Ex Addressing"
1657 commands are executed from
1659 relates to the current line.
1660 In general, the current line is the last line affected by a command.
1661 The exact effect on the current line is discussed under the description
1663 When the file contains no lines, the current line is zero.
1665 Addresses are constructed by one or more of the following methods:
1669 refers to the current line.
1673 refers to the last line of the file.
1679 is a positive number, refers to the N-th line of the file.
1685 refers to the line marked with the name
1691 commands for more information on how to mark lines.)
1693 A regular expression (RE) enclosed by slashes
1696 and it refers to the first line found by searching forward from the line
1698 the current line toward the end of the file, and stopping at the
1699 first line containing a string matching the RE.
1700 (The trailing slash can be omitted at the end of the command line.)
1702 If no RE is specified, i.e. the pattern is
1704 the last RE used in any command is used in the search.
1708 option is set, the RE is handled as an extended RE, not a basic RE.
1711 option is set, the search wraps around to the beginning of the file
1712 and continues up to and including the current line, so that the entire
1717 is accepted for historic reasons,
1721 An RE enclosed in question marks
1723 addresses the first line found by searching backward from the line
1725 the current line, toward the beginning of the file and stopping at the
1726 first line containing a string matching the RE.
1727 (The trailing question mark can be omitted at the end of a command line.)
1729 If no RE is specified, i.e. the pattern is
1731 the last RE used in any command is used in the search.
1735 option is set, the RE is handled as an extended RE, not a basic RE.
1738 option is set, the search wraps around from the beginning of the file to
1739 the end of the file and continues up to and including the current line,
1740 so that the entire file is searched.
1744 is accepted for historic reasons, and is identical to
1747 An address followed by a plus sign
1751 followed by a number is an offset address and refers to the address
1752 plus (or minus) the indicated number of lines.
1753 If the address is omitted, the addition or subtraction is done with
1754 respect to the current line.
1760 followed by a number is an offset from the current line.
1766 An address ending with
1770 has 1 added to or subtracted from the address, respectively.
1771 As a consequence of this rule and of the previous rule, the address
1773 refers to the line preceding the current line.
1778 characters have a cumulative effect.
1781 refers to the current line plus 3.
1785 is equivalent to the address range
1789 commands require zero, one, or two addresses.
1790 It is an error to specify an address to a command which requires zero
1793 If the user provides more than the expected number of addresses to any
1795 command, the first addresses specified are discarded.
1798 prints lines 3 through 5, because the
1800 command only takes two addresses.
1802 The addresses in a range are separated from each other by a comma
1806 In the latter case, the current line
1808 is set to the first address, and only then is the second address calculated.
1809 This feature can be used to determine the starting line for forward and
1810 backward searches (see rules (5) and (6) above).
1811 The second address of any two-address sequence corresponds to a line that
1812 follows, in the file, the line corresponding to the first address.
1813 The first address must be less than or equal to the second address.
1814 The first address must be greater than or equal to the first line of the
1815 file, and the last address must be less than or equal to the last line
1817 .oh 'Vi/Ex Reference (Ex Commands)''USD:13-%'
1818 .eh 'USD:13-%''Vi/Ex Reference (Ex Commands)'
1820 .oh 'Vi/Ex Reference (Options)''USD:13-%'
1821 .eh 'USD:13-%''Vi/Ex Reference (Options)'
1823 .oh 'Vi/Ex Reference''USD:13-%'
1824 .eh 'USD:13-%''Vi/Ex Reference'
1833 .\" Force the TOC to an odd page, in case it's a duplex printer.
1838 \fB\s+2Table of Contents\s0\fP