1 .\" $NetBSD: vi.ref,v 1.2 2014/09/10 21:44:22 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 .\" This document may not be republished without written permission from
11 .\" See the LICENSE file for redistribution information.
13 .\" @(#)vi.ref 8.88 (Berkeley) 10/19/96
21 Vi/Ex Reference Manual
27 Computer Science Division
28 Department of Electrical Engineering and Computer Science
29 University of California, Berkeley
30 Berkeley, California 94720
40 This document is the reference guide for the 4.4BSD
43 which are implementations of the historic Berkeley
53 Copyright (c) 1991, 1992, 1993, 1994
55 The Regents of the University of California. All Rights Reserved.
57 Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996
59 Keith Bostic. All Rights Reserved.
62 The vi program is freely redistributable. You are welcome to copy,
63 modify and share it with others under the conditions listed in the
64 LICENSE file. If any company (not individual!) finds vi sufficiently
65 useful that you would have purchased it, or if any company wishes to
66 redistribute it, contributions to the authors would be appreciated.
74 Bruce Englar encouraged the early development of the historic
77 Peter Kessler helped bring sanity to version 2's command layout.
78 Bill Joy wrote versions 1 and 2.0 through 2.7,
79 and created the framework that users see in the present editor.
80 Mark Horton added macros and other features and made
82 work on a large number of terminals and Unix systems.
85 is originally derived from software contributed to the University of
86 California, Berkeley by Steve Kirkendall, the author of the
91 IEEE Standard Portable Operating System Interface for Computer
92 Environments (POSIX) 1003.2 style Regular Expression support was
93 done by Henry Spencer.
95 The curses library was originally done by Ken Arnold.
96 Scrolling and reworking for
98 was done by Elan Amir.
100 George Neville-Neil added the Tcl interpreter,
101 and Sven Verdoolaege added the Perl interpreter.
103 Rob Mayoff added Cscope support.
105 The Institute of Electrical and Electronics Engineers has
106 given us permission to reprint portions of their documentation.
107 Portions of this document are reprinted and reproduced from
108 IEEE Std 1003.2-1992, IEEE Standard Portable Operating
109 System Interface for Computer Environments (POSIX),
110 copyright 1992 by the Institute of Electrical and Electronics
113 The financial support of UUNET Communications Services is gratefully
116 .if \n[.U]==0 .sy echo -n >index
117 .oh 'Vi/Ex Reference''USD:13-%'
118 .eh 'USD:13-%''Vi/Ex Reference'
123 is a screen oriented text editor.
125 is a line-oriented text editor.
129 are different interfaces to the same program,
130 and it is possible to switch back and forth during an edit session.
132 is the equivalent of using the
134 (read-only) option of
137 This reference manual is the one provided with the
143 are intended as bug-for-bug compatible replacements for the original
144 Fourth Berkeley Software Distribution (4BSD)
147 This reference manual is accompanied by a traditional-style manual page.
148 That manual page describes the functionality found in
150 in far less detail than the description here.
151 In addition, it describes the system interface to
153 e.g. command line options, session recovery, signals,
154 environmental variables, and similar things.
156 This reference is intended for users already familiar with
158 Anyone else should almost certainly read a good tutorial on the
160 If you are in an unfamiliar environment,
161 and you absolutely have to get work done immediately,
162 see the section entitled
165 It is probably enough to get you started.
167 There are a few features in
169 that are not found in historic versions of
171 Some of the more interesting of those features are briefly described
172 in the next section, entitled
173 .QB "Additional Features" .
174 For the rest of this document,
176 is used only when it is necessary to distinguish it from the historic
180 Future versions of this software will be periodically made available
181 by anonymous ftp, and can be retrieved from
182 .LI ftp.cs.berkeley.edu ,
185 .SH 1 "Additional Features in Nex/Nvi"
187 There are a few features in
189 that are not found in historic versions of
191 Some of the more interesting of these are as follows:
192 .IP "8-bit clean data, large lines, files"
194 will edit any format file.
195 Line lengths are limited by available memory,
196 and file sizes are limited by available disk space.
199 text input mode command
201 can insert any possible character value into the text.
202 .IP "Background and foreground screens"
205 command backgrounds the current screen, and the
207 command foregrounds backgrounded screens.
210 command can be used to list the background screens.
211 .IP "Command Editing"
212 You can enter a normal editing window on the collected commands that
213 you've entered on the
216 and then modify and/or execute the commands.
219 edit option for more information.
223 command can be used to display the current buffers, the backgrounded
224 screens, and the tags stack.
225 .IP "Extended Regular Expressions"
228 option causes Regular Expressions to be interpreted as as Extended
229 Regular Expressions, (i.e. \fIegrep\fP(1) style Regular Expressions).
230 .IP "File Name Completion"
231 It is possible to do file name completion and file name displays when
232 entering commands on the
237 option for more information.
239 Changes made during an edit session may be rolled backward and forward.
242 command immediately after a
244 command continues either forward or backward depending on whether the
246 command was an undo or a redo.
247 .IP "Left-right scrolling"
252 to do left-right screen scrolling, instead of the traditional
255 .IP "Message Catalogs"
256 It is possible to display informational and error messages in different
257 languages by providing a catalog of messages.
262 for more information.
263 .IP "Incrementing numbers"
266 command increments or decrements the number referenced by the cursor.
270 command edits the previous file from the argument list.
271 .IP "Scripting languages"
277 commands execute Perl and Tcl/Tk commands, respectively,
278 on lines from the edit buffer.
280 .QB "Scripting Languages"
281 section and the specific commands for more information.
282 .\".IP "Shell screens"
284 .\".CO ":sc[ript] [file ...]"
285 .\"command runs a shell in the screen.
286 .\"Editing is unchanged, with the exception that a \fC<carriage-return>\fP
287 .\"enters the current line (stripped of any prompt) as input to the
300 mode) commands divide the screen into multiple editing regions and
301 then perform their normal function in a new screen area.
304 command rotates between the foreground screens.
307 command can be used to grow or shrink a particular screen.
309 Tags are now maintained in a stack.
312 command returns to the previous tag location.
315 command returns to the most recent tag location by default, or,
316 optionally to a specific tag number in the tag stack,
317 or the most recent tag from a specified file.
320 command can be used to list the tags stack.
323 command returns to the top of the tag stack.
324 .IP "Usage information"
329 commands provide usage information for all of the
333 commands by default, or, optionally, for a specific command or key.
337 command searches for the word referenced by the cursor.
338 .SH 1 "Startup Information"
341 interprets one of two possible environmental variables and reads up to
342 three of five possible files during startup.
343 The variables and files are expected to contain
348 In addition, they are interpreted
350 the file to be edited is read, and therefore many
352 commands may not be used.
353 Generally, any command that requires output to the screen or that
354 needs a file upon which to operate, will cause an error if included
355 in a startup file or environmental variable.
359 command set supported by
361 is a superset of the command set supported by historical implementations of
364 can use the startup files created for the historical implementations,
365 but the converse may not be true.
369 (the historic \- option)
370 is specified, or if standard input is redirected from a file,
371 all environmental variables and startup files are ignored.
373 Otherwise, startup files and environmental variables are handled
374 in the following order:
379 as long as it is owned by root or the effective user ID of the user.
381 The environmental variable
387 is not set) is interpreted.
395 environmental variable is set, the file
401 does not exist) is read,
402 as long as the effective user ID of the user is root or is the same as
403 the owner of the file.
405 When the $HOME directory is being used for both
407 and an historic implementation of
409 a possible solution is to put
411 specific commands in the
414 .CO ":source $HOME/.exrc"
415 command to read in the commands common to both implementations.
419 option was turned on by one of the previous startup information
426 does not exist) is read, as long as the effective user ID of the user
427 is the same as the owner of the file.
429 No startup file is read if it is writable by anyone other than its owner.
431 It is not an error for any of the startup environmental variables or files
434 Once all environmental variables are interpreted,
435 and all startup files are read,
436 the first file to be edited is read in (or a temporary file is created).
438 As soon as an existing file is loaded
439 (either due to the command line parameters or from within the editor),
440 any command specified using the
442 option is executed, in the context of that file.
443 Note that such a command is an
445 command and thus obeys the
447 behaviour by first jumping to the end of the file, even if used with
451 There is no recovery program for
456 Recovery files are created readable and writable by the owner only.
457 Users may recover any file which they can read,
458 and the superuser may recover any edit session.
460 Edit sessions are backed by files in the directory named by the
462 option (the directory
463 .LI /var/tmp/vi.recover
464 by default), and are named
468 is a number related to the process ID.
469 When a file is first modified,
470 a second recovery file containing an email message for the user is created,
475 is associated with the process ID.
476 Both files are removed at the end of a normal edit session,
477 but will remain if the edit session is abnormally terminated
485 option may be set in either the user's or system's startup information,
486 changing the recovery directory.
487 (Note, however, that if a memory based file system is used as the backup
488 directory, each system reboot will delete all of the recovery files!
489 The same caution applies to directories such as
491 which are cleared of their contents by a system reboot, or
493 which is periodically cleared of old files on many systems.)
495 The recovery directory should be owned by root, or at least by a pseudo-user.
496 In addition, if directory
498 semantics are available, the directory should have the sticky-bit
499 set so that files may only be removed by their owners.
500 The recovery directory must be read, write, and executable by any user,
503 If the recovery directory does not exist,
505 will attempt to create it.
506 This can result in the recovery directory being owned by a normal user,
507 which means that that user will be able to remove other user's recovery
509 This is annoying, but is not a security issue as the user cannot
510 otherwise access or modify the files.
512 The recovery file has all of the necessary information in it to enable the
513 user to recover the edit session.
514 In addition, it has all of the necessary email headers for
516 When the system is rebooted, all of the files in
517 .LI /var/tmp/vi.recover
520 should be sent to their owners, by email, using the
524 (or a similar mechanism in other mailers).
527 receives a hangup (SIGHUP) signal, or the user executes the
532 will automatically email the recovery information to the user.
534 If your system does not have the
536 utility (or a mailer program which supports its interface)
538 .LI nvi/common/recover.c
539 will have to be modified to use your local mail delivery programs.
542 is changed to use another mailer,
543 it is important to remember that the owner of the file given to
546 user, so nothing in the file should be trusted as it may have been
547 modified in an effort to compromise the system.
549 Finally, the owner execute bit is set on backup files when they are
550 created, and unset when they are first modified, e.g. backup files
551 that have no associated email recovery file will have this bit set.
552 (There is also a small window where empty files can be created and
553 not yet have this bit set.
554 This is due to the method in which the files are created.)
555 Such files should be deleted when the system reboots.
557 A simple way to do this cleanup is to run the Bourne shell script
561 (or other system startup) file.
562 The script should work with the historic Bourne shell,
563 a POSIX 1003.2 shell or the Korn shell.
566 script is installed as part of the
568 installation process.
570 Consult the manual page for details on recovering preserved or
571 aborted editing sessions.
572 .SH 1 "Sizing the Screen"
574 The size of the screen can be set in a number of ways.
576 takes the following steps until values are obtained for both the
577 number of rows and number of columns in the screen.
579 If the environmental variable
582 it is used to specify the number of rows in the screen.
584 If the environmental variable
587 it is used to specify the number of columns in the screen.
591 is attempted on the standard error file descriptor.
593 The termcap entry (or terminfo entry on System V machines)
600 The number of rows is set to 24, and the number of columns is set to 80.
602 If a window change size signal (SIGWINCH) is received,
603 the new window size is retrieved using the TIOCGWINSZ
605 call, and all other information is ignored.
606 .SH 1 "Character Display"
612 printable characters as defined by
614 are displayed using the local character set.
616 Non-printable characters, for which
618 returns true, and which are less than octal \e040,
619 are displayed as the string
623 is the character that is the original character's value offset from the
626 For example, the octal character \e001 is displayed as
630 returns true for the octal character \e177,
631 it is displayed as the string
633 All other characters are displayed as either hexadecimal values,
635 .QT "0x<high-halfbyte> ... 0x<low-halfbyte>" ,
636 or as octal values, in the form
637 .QT "\e<high-one-or-two-bits> ... \e<low-three-bits>" .
638 The display of unknown characters is based on the value of the
644 command mode, the cursor is always positioned on the last column of
645 characters which take up more than one column on the screen.
648 text input mode, the cursor is positioned on the first column of
649 characters which take up more than one column on the screen.
650 .SH 1 "Multiple Screens"
653 supports multiple screens by dividing the window into regions.
654 It also supports stacks of screens by permitting the user to change
655 the set of screens that are currently displayed.
669 commands divide the current screen into two regions of approximately
670 equal size and then perform their usual action in a new screen area.
671 If the cursor is in the lower half of the screen, the screen will split
672 up, i.e. the new screen will be above the old one.
673 If the cursor is in the upper half of the screen, the new screen will be
676 When more than one screen is editing a file, changes in any screen are
677 reflected in all other screens editing the same file.
678 Exiting a screen without saving any changes (or explicitly discarding
679 them) is permitted until the last screen editing the file is exited,
680 at which time the changes must be saved or discarded.
684 command permits resizing of individual screens.
685 Screens may be grown, shrunk or set to an absolute number of rows.
689 command is used to switch between screens.
692 moves to the next lower screen in the window, or to the first screen
693 in the window if there are no lower screens.
700 The screen disappears from the window,
701 and the rows it occupied are taken over by a neighboring screen.
702 It is an error to attempt to background the only screen in the window.
705 .CO "display screens"
706 command displays the names of the files associated with the current
707 backgrounded screens in the window.
711 command moves the specified screen from the list of backgrounded screens
713 If no file argument is specified, the first screen on the list is
716 foregrounding consists of backgrounding the current screen,
717 and replacing its space in the window with the foregrounded screen.
719 Capitalizing the first letter of the command, i.e.
721 will foreground the backgrounded screen in a new screen instead of
722 swapping it with the current screen.
724 If the last foregrounded screen in the window is exited,
725 and there are backgrounded screens,
726 the first screen on the list of backgrounded screens takes over the window.
727 .SH 1 "Tags, Tag Stacks, and Cscope"
730 supports the historic
738 These commands change the current file context to a new location,
739 based on information found in the
742 If you are unfamiliar with these commands,
743 you should review their description in the
747 commands section of this manual.
748 For additional information on tags files,
749 see the discussion of the
751 edit option and the system
757 supports the notion of
764 command returns the user to the previous context, i.e.,
765 the last place from which a
770 These three commands provide the basic functionality which allows you
773 to review source code in a structured manner.
776 also provides two other basic
778 commands for tag support:
784 command is identical to the
787 with the additional functionality that you may specify that modifications
788 to the current file are to be discarded.
789 This cannot be done using the
794 command discards all of the contexts that have been pushed onto the tag
795 stack, returning to the context from which the first
803 tags file format supports only a single location per tag,
804 normally the function declaration or structure or string definition.
805 More sophisticated source code tools often provide multiple locations
807 a list of the places from which a function is called or a string
809 An example of this functionality is the System V source code tool,
813 creates a database of information on source code files,
814 and supports a query language for that information as described in the
818 contains an interface to the
820 query language which permits you to query
822 and then sequentially step through the locations in the sources files which
827 commands which support this ability to step through multiple locations.
836 command moves to the next location for the current tag.
839 command moves to the previous location for the current tag.
844 command discussion in the
846 commands section of this manual for more information.)
847 At any time during this sequential walk,
853 commands to move to a new tag context, and then use the
857 commands to return and continue stepping through the locations for this
859 This is similar to the previous model of a simple tag stack,
860 except that each entry in the tag stack may have more than one file context
863 Although there is no widely distributed version of
865 that creates tags files with multiple locations per tag,
867 has been written to understand the obvious extension to the historic
868 tags file format, i.e., more than a single line in the tags file with
869 the same initial tag name.
870 If you wish to extend your
872 implementation or other tool with which you build tags files,
873 this extension should be simple and will require no changes to
880 interface is based on the new
884 which has five subcommands:
893 itself has eight subcommands:
904 .IP "cs[cope] a[dd] file"
907 command attaches to the specified
910 The file name is expanded using the standard filename expansions.
913 is a directory, the file
915 in that directory is used as the database.
919 attaches to a new database,
922 queries will be asked of that database.
923 The result of any single query is the collection of response to the query
924 from all of the attached databases.
928 environmental variable is set when
931 it is expected to be a <colon> or <blank>-separated list of
933 databases or directories containing
935 databases, to which the user wishes to attach.
936 .IP ":cs[cope] f[ind] c|d|e|f|g|i|s|t buffer|pattern"
947 databases for the pattern.
948 If the pattern is a double-quote character followed by a valid buffer
950 .LI """<character>" ),
951 then the contents of the named buffer are used as the pattern.
952 Otherwise, the pattern is a Regular Expression.
956 command pushes the current location onto the tags stack,
957 and switches to the first location resulting from the query,
958 if the query returned at least one result.
960 File names returned by the
962 query, if not absolute paths, are searched for relative to the directory
966 In addition, if the file
968 appears in the same directory as the
971 it is expected to contain a colon-separated list of directory names
972 where files referenced by its associated
974 database may be found.
978 subcommand is one of the following:
981 Find callers of the name.
983 Find all function calls made from name.
987 Find files with name as substring.
989 Find definition of name.
991 Find files #including name.
993 Find all uses of name.
995 Find assignments to name.
997 .IP ":cs[cope] h[elp] [command]"
1001 or optionally list usage help for any single
1004 .IP ":display c[onnections]"
1009 is currently connected.
1010 .IP ":cs[cope] k[ill] #"
1011 Disconnect from a specific
1014 The connection number is the one displayed by the
1016 .CO "display connections"
1018 .IP ":cs[cope] r[eset]"
1019 Disconnect from all attached
1023 Cscope is not freely redistributable software,
1024 but is fairly inexpensive and easily available.
1025 To purchase a copy of
1027 see http://www.att.com/ssg/products/toolchest.html.
1028 .SH 1 "Regular Expressions and Replacement Strings"
1030 Regular expressions are used in line addresses,
1031 as the first part of the
1037 commands, and in search patterns.
1039 The regular expressions supported by
1041 are, by default, the Basic Regular Expressions (BRE's) described in the
1042 IEEE POSIX Standard 1003.2.
1045 option causes all regular expressions to be interpreted as the Extended
1046 Regular Expressions (ERE's) described by the same standard.
1049 for more information.)
1050 Generally speaking, BRE's are the Regular Expressions found in
1054 and ERE's are the Regular Expressions found in
1057 The following is not intended to provide a description of Regular
1059 The information here only describes strings and characters which
1060 have special meanings in the
1063 or options which change the meanings of characters that normally
1064 have special meanings in RE's.
1070 is equivalent to the last RE used.
1074 matches the beginning of a word.
1078 matches the end of a word.
1082 matches the replacement part of the last
1090 set, the only characters with special meanings are a
1092 character at the beginning of an RE, a
1094 character at the end of an RE, and the escaping character
1102 are treated as ordinary characters unless preceded by a
1106 they regain their special meaning.
1108 Replacement strings are the second part of a
1120 set) in the replacement string stands for the text matched by the RE
1121 that is being replaced.
1130 set) stands for the replacement part of the previous
1133 It is only valid after a
1135 command has been performed.
1141 is an integer value from 1 to 9, stands for the text matched by
1142 the portion of the RE enclosed in the
1144 set of escaped parentheses, e.g.
1149 .QT "s/abc\e(.*\e)def/\e1/"
1154 from the matched pattern.
1162 can be used to modify the case of elements in the replacement string.
1165 causes the next character to be converted to lowercase;
1168 behaves similarly, but converts to uppercase
1177 causes characters up to the end of the string or the next occurrence
1182 to be converted to lowercase;
1185 behaves similarly, but converts to uppercase.
1187 If the entire replacement pattern is
1189 then the last replacement pattern is used again.
1195 into the replacement string will cause
1196 the matched line to be split into two lines at that point.
1200 .SH 1 "Scripting Languages"
1204 editor currently supports two scripting languages, Tcl/Tk and Perl.
1205 (Note that Perl4 isn't sufficient, and that the Perl5 used must be
1206 version 5.002 or later.
1209 section for more information.
1211 The scripting language interface is still being worked on,
1212 therefore the following information is probably incomplete,
1213 probably wrong in cases, and likely to change.
1218 source directories for more information.
1219 As a quick reference, the following function calls are provided for
1220 both the Perl and Tcl interfaces.
1221 The Perl interface uses a slightly different naming convention,
1222 e.g. ``viFindScreen'' is named ``VI::FindScreen''.
1223 .IP "viFindScreen file"
1225 .LI "screenId" associated with
1227 .IP "viAppendLine screenId lineNumber text"
1230 as a new line after line number
1234 .IP "viDelLine screenId lineNum"
1239 .IP "viGetLine screenId lineNumber"
1244 .IP "viInsertLine screenId lineNumber text"
1247 as a new line before line number
1251 .IP "viLastLine screenId"
1252 Return the line number of the last line in the screen
1254 .IP "viSetLine screenId lineNumber text"
1259 to match the specified
1261 .IP "viGetMark screenId mark"
1262 Return the current line and column for the specified
1266 .IP "viSetMark screenId mark line column"
1275 .IP "viGetCursor screenId"
1276 Return the current line and column for the cursor in the screen
1278 .IP "viSetCursor screenId line column"
1279 Set the cursor in the screen
1285 .IP "viMsg screenId text"
1286 Display the specified
1288 as a vi message in the screen
1290 .IP "viNewScreen screenId [file]"
1291 Create a new screen.
1292 .IP "viEndScreen screenId"
1295 .IP "viSwitchScreen screenId screenId"
1296 Switch from the screen
1300 .IP "viMapKey screenId key tclproc"
1305 to the Tcl procedure
1307 .IP "viUnmMapKey screenId key"
1312 .IP "viGetOpt screenId option"
1313 Return the value of the specified
1317 .IP "viSetOpt screenId command"
1318 Set one or more options in the screen
1320 .SH 1 "General Editor Description"
1327 the text of a file is read (or a temporary file is created),
1328 and then all editing changes happen within the context of the
1330 .i "No changes affect the actual file until the file is written out" ,
1331 either using a write command or another command which is affected by the
1335 All files are locked (using the
1339 interfaces) during the edit session,
1340 to avoid inadvertently making modifications to multiple copies of the file.
1341 If a lock cannot be obtained for a file because it is locked by another
1342 process, the edit session is read-only (as if the
1346 flag had been specified).
1347 If a lock cannot be obtained for other reasons, the edit session will
1348 continue, but the file status information
1351 command) will reflect this fact.
1357 are modeful editors, i.e. they have two modes,
1362 The former is intended to permit you to enter commands which modifies
1363 already existing text.
1364 The latter is intended to permit you to enter new text.
1367 first starts running, it is in command mode, and usually displays a prompt
1370 option for more information).
1371 The prompt is a single colon
1374 There are three commands that switch
1376 into text input mode:
1381 Once in input mode, entering a line containing only a single period
1383 ends text input mode and returns to command mode,
1384 where the prompt is redisplayed.
1388 first starts running, it is in command mode as well.
1389 There are eleven commands that switch
1391 into text input mode:
1404 Once in input mode, entering an
1406 character ends text input mode and returns to command mode.
1409 present three different interfaces to editing a file.
1411 presents a line oriented interface.
1413 presents a full screen display oriented interface,
1416 In addition, there is a third mode,
1418 which is line oriented,
1419 but supports cursor movement and editing within the displayed line,
1420 similarly to visual mode.
1421 Open mode is not yet implemented in
1424 The following words have special meanings in both the
1428 command descriptions:
1431 The interrupt character is used to interrupt the current operation.
1434 whatever character is set for the current terminal is used.
1435 .KY "<literal-next>"
1436 .IP "<literal-next>"
1437 The literal next character is used to escape the subsequent character
1438 from any special meaning.
1439 This character is always
1441 If the terminal is not set up to do XON/XOFF flow control,
1444 is used to mean literal next as well.
1445 .KY "current pathname"
1446 .IP "current pathname"
1447 The pathname of the file currently being edited by vi.
1448 When the percent character
1450 appears in a file name entered as part of an
1452 command argument, it is replaced by the current pathname.
1455 character can be escaped by preceding it with a backslash.)
1456 .KY "alternate pathname"
1457 .IP "alternate pathname"
1458 The name of the last file name mentioned in an
1461 the previous current pathname if the last file mentioned
1462 becomes the current file.
1463 When the hash mark character
1465 appears in a file name entered as part of an
1467 command argument, it is replaced by the alternate pathname.
1470 character can be escaped by preceding it with a backslash.)
1473 One of a number of named areas for saving copies of text.
1474 Commands that change or delete text can save the changed or deleted
1475 text into a specific buffer, for later use, if the command allows
1479 command cannot save the changed text in a named buffer).
1480 Buffers are named with a single character, preceded by a double quote,
1486 without the double quote, e.g.
1490 (The double quote isn't necessary for
1492 because buffers names are denoted by their position in the command line.)
1493 Historic implementations of
1497 to the alphanumeric characters;
1499 permits the use of any character without another meaning in the position
1500 where a buffer name is expected.
1502 Buffers named by uppercase characters are the same as buffers
1503 named by lowercase characters, e.g. the buffer named by the
1506 is the same as the buffer named by the character
1508 with the exception that, if the buffer contents are being changed (as
1509 with a text deletion or
1512 command), the text is
1514 to the buffer, instead of replacing the current contents.
1516 The buffers named by the numeric characters (in English,
1521 If a region of text including characters from more than one line,
1522 or a single line of text specified by using a line-oriented motion,
1523 is changed or deleted in the file using the
1528 commands, a copy of the text is placed into the numeric buffer
1530 regardless of the user specifying another buffer in which to save it.
1531 In addition, there are a few commands which, when used as a
1540 copy the specified region of text into the numeric buffers regardless
1541 of the region including characters from more than one line.
1554 Before this copy is done, the previous contents of buffer
1556 are moved into buffer
1562 The contents of buffer
1567 text may be explicitly stored into the numeric buffers.
1568 In this case, the buffer rotation described above occurs before the
1569 replacement of the buffer's contents.
1570 The numeric buffers are only available in
1575 and are not accessible by
1577 in any way, although changed and deleted text is still stored there
1584 command synopsis shows both a
1588 they may be presented in any order.
1590 Finally, all buffers are either
1597 commands which store text into buffers are line oriented.
1600 commands which store text into buffers are line oriented,
1601 and some are character oriented; the description for each applicable
1603 command notes whether text copied into buffers using the command
1604 is line or character oriented.
1608 .CO "display buffers"
1609 displays the current orientation for each buffer.
1610 Generally, the only importance attached to this orientation is that
1611 if the buffer is subsequently inserted into the text, line oriented
1612 buffers create new lines for each of the lines they contain, and
1613 character oriented buffers create new lines for any lines
1615 than the first and last lines they contain.
1616 The first and last lines are inserted into the text at the current
1617 cursor position, becoming part of the current line.
1618 If there is more than one line in the buffer, however, the current
1619 line itself will be split.
1620 .KY "unnamed buffer"
1621 .IP "unnamed buffer"
1622 The unnamed buffer is a text storage area which is used by commands
1623 that use or operate on a buffer when no buffer is specified by the user.
1624 If the command stores text into a buffer,
1625 the text is stored into the unnamed buffer even if a buffer is also
1626 specified by the user.
1627 It is not possible to append text to the unnamed buffer.
1628 If text is appended to a named buffer,
1629 the named buffer contains both the old and new text,
1630 while the unnamed buffer contains only the new text.
1631 There is no way to explicitly reference the unnamed buffer.
1633 Historically, the contents of the unnamed buffer were discarded by many
1634 different commands, even ones that didn't store text into it.
1636 never discards the contents of the unnamed buffer until new text
1640 The characters <tab> and <space>.
1641 .KY "<carriage-return>"
1642 .IP "<carriage-return>"
1643 The character represented by an ASCII
1645 This character is almost always treated identically to a
1647 character, but differs in that it can be escaped into the file text or
1651 The character represented by an ASCII
1653 This character is almost always treated identically to a
1655 character, but differs in that it cannot be escaped into the file text or
1657 .oh 'Vi/Ex Reference (Vi Commands)''USD:13-%'
1658 .eh 'USD:13-%''Vi/Ex Reference (Vi Commands)'
1660 .oh 'Vi/Ex Reference''USD:13-%'
1661 .eh 'USD:13-%''Vi/Ex Reference'
1662 .SH 1 "Ex Addressing"
1668 commands are executed from
1670 relates to the current line.
1671 In general, the current line is the last line affected by a command.
1672 The exact effect on the current line is discussed under the description
1674 When the file contains no lines, the current line is zero.
1676 Addresses are constructed by one or more of the following methods:
1680 refers to the current line.
1684 refers to the last line of the file.
1690 is a positive number, refers to the N-th line of the file.
1696 refers to the line marked with the name
1702 commands for more information on how to mark lines.)
1704 A regular expression (RE) enclosed by slashes
1707 and it refers to the first line found by searching forward from the line
1709 the current line toward the end of the file, and stopping at the
1710 first line containing a string matching the RE.
1711 (The trailing slash can be omitted at the end of the command line.)
1713 If no RE is specified, i.e. the pattern is
1715 the last RE used in any command is used in the search.
1719 option is set, the RE is handled as an extended RE, not a basic RE.
1722 option is set, the search wraps around to the beginning of the file
1723 and continues up to and including the current line, so that the entire
1728 is accepted for historic reasons,
1732 An RE enclosed in question marks
1734 addresses the first line found by searching backward from the line
1736 the current line, toward the beginning of the file and stopping at the
1737 first line containing a string matching the RE.
1738 (The trailing question mark can be omitted at the end of a command line.)
1740 If no RE is specified, i.e. the pattern is
1742 the last RE used in any command is used in the search.
1746 option is set, the RE is handled as an extended RE, not a basic RE.
1749 option is set, the search wraps around from the beginning of the file to
1750 the end of the file and continues up to and including the current line,
1751 so that the entire file is searched.
1755 is accepted for historic reasons, and is identical to
1758 An address followed by a plus sign
1762 followed by a number is an offset address and refers to the address
1763 plus (or minus) the indicated number of lines.
1764 If the address is omitted, the addition or subtraction is done with
1765 respect to the current line.
1771 followed by a number is an offset from the current line.
1777 An address ending with
1781 has 1 added to or subtracted from the address, respectively.
1782 As a consequence of this rule and of the previous rule, the address
1784 refers to the line preceding the current line.
1789 characters have a cumulative effect.
1792 refers to the current line plus 3.
1796 is equivalent to the address range
1800 commands require zero, one, or two addresses.
1801 It is an error to specify an address to a command which requires zero
1804 If the user provides more than the expected number of addresses to any
1806 command, the first addresses specified are discarded.
1809 prints lines 3 through 5, because the
1811 command only takes two addresses.
1813 The addresses in a range are separated from each other by a comma
1817 In the latter case, the current line
1819 is set to the first address, and only then is the second address calculated.
1820 This feature can be used to determine the starting line for forward and
1821 backward searches (see rules (5) and (6) above).
1822 The second address of any two-address sequence corresponds to a line that
1823 follows, in the file, the line corresponding to the first address.
1824 The first address must be less than or equal to the second address.
1825 The first address must be greater than or equal to the first line of the
1826 file, and the last address must be less than or equal to the last line
1828 .oh 'Vi/Ex Reference (Ex Commands)''USD:13-%'
1829 .eh 'USD:13-%''Vi/Ex Reference (Ex Commands)'
1831 .oh 'Vi/Ex Reference (Options)''USD:13-%'
1832 .eh 'USD:13-%''Vi/Ex Reference (Options)'
1834 .oh 'Vi/Ex Reference''USD:13-%'
1835 .eh 'USD:13-%''Vi/Ex Reference'
1844 .\" Force the TOC to an odd page, in case it's a duplex printer.
1849 \fB\s+2Table of Contents\s0\fP