2 @setfilename vi.ref.info
7 @comment Copyright (c) 1994
8 @comment The Regents of the University of California. All rights reserved.
9 @comment Copyright (c) 1994, 1995, 1996
10 @comment Keith Bostic. All rights reserved.
12 @comment This document may not be republished without written permission from
13 @comment Keith Bostic.
15 @comment See the LICENSE file for redistribution information.
17 @comment Id: vi.texi,v 8.1 2001/08/18 20:43:50 skimo Exp (Berkeley) Date: 2001/08/18 20:43:50
23 * vi: (vi.info). The vi editor.
26 @node Top,(dir),(dir),(dir)
33 @center @titlefont{Vi/Ex Reference Manual}
35 @center @emph{Keith Bostic}
37 @center Computer Science Division
38 @center Department of Electrical Engineering and Computer Science
39 @center University of California, Berkeley
40 @center Berkeley, California 94720
42 @center @emph{Sven Verdoolaege}
46 @center @emph{Abstract}
48 This document is the reference guide for the 4.4BSD
51 which are implementations of the historic Berkeley
54 @vskip 0pt plus 1filll
55 Copyright @copyright{} 1991, 1992, 1993, 1994@*
56 @hskip 2cm The Regents of the University of California. All Rights Reserved.@*
57 Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996@*
58 @hskip 2cm Keith Bostic. All Rights Reserved.@*
59 Copyright @copyright{} 2001@*
60 @hskip 2cm Sven Verdoolaege. All Rights Reserved.@*
62 @center@emph{Acknowledgements}
65 Bruce Englar encouraged the early development of the historic
68 Peter Kessler helped bring sanity to version 2's command layout.
69 Bill Joy wrote versions 1 and 2.0 through 2.7,
70 and created the framework that users see in the present editor.
71 Mark Horton added macros and other features and made
73 work on a large number of terminals and Unix systems.
76 is originally derived from software contributed to the University of
77 California, Berkeley by Steve Kirkendall, the author of the
82 IEEE Standard Portable Operating System Interface for Computer
83 Environments (POSIX) 1003.2 style Regular Expression support was
84 done by Henry Spencer.
86 The curses library was originally done by Ken Arnold.
87 Scrolling and reworking for
89 was done by Elan Amir.
91 George Neville-Neil added the Tcl interpreter,
92 and Sven Verdoolaege added the Perl interpreter.
94 Rob Mayoff added Cscope support.
96 The Institute of Electrical and Electronics Engineers has
97 given us permission to reprint portions of their documentation.
98 Portions of this document are reprinted and reproduced from
99 IEEE Std 1003.2-1992, IEEE Standard Portable Operating
100 System Interface for Computer Environments (POSIX),
101 copyright 1992 by the Institute of Electrical and Electronics
104 The financial support of UUNET Communications Services is gratefully
111 is a screen oriented text editor.
113 is a line-oriented text editor.
117 are different interfaces to the same program,
118 and it is possible to switch back and forth during an edit session.
120 is the equivalent of using the
122 (read-only) option of
125 This reference manual is the one provided with the
131 are intended as bug-for-bug compatible replacements for the original
132 Fourth Berkeley Software Distribution (4BSD)
135 This reference manual is accompanied by a traditional-style manual page.
136 That manual page describes the functionality found in
138 in far less detail than the description here.
139 In addition, it describes the system interface to
141 e.g. command line options, session recovery, signals,
142 environmental variables, and similar things.
144 This reference is intended for users already familiar with
146 Anyone else should almost certainly read a good tutorial on the
148 If you are in an unfamiliar environment,
149 and you absolutely have to get work done immediately,
150 see the section entitled
153 It is probably enough to get you started.
155 There are a few features in
157 that are not found in historic versions of
159 Some of the more interesting of those features are briefly described
160 in the next section, entitled
161 @QB{Additional Features} .
162 For the rest of this document,
164 is used only when it is necessary to distinguish it from the historic
168 Future versions of this software will be periodically made available
169 by anonymous ftp, and can be retrieved from
170 @LI{ftp.cs.berkeley.edu},
173 @chapter Additional Features in Nex/Nvi
175 There are a few features in
177 that are not found in historic versions of
179 Some of the more interesting of these are as follows:
181 @IP{8-bit clean data, large lines, files}
184 will edit any format file.
185 Line lengths are limited by available memory,
186 and file sizes are limited by available disk space.
189 text input mode command
191 can insert any possible character value into the text.
192 @IP{Background and foreground screens}
196 command backgrounds the current screen, and the
198 command foregrounds backgrounded screens.
201 command can be used to list the background screens.
204 You can enter a normal editing window on the collected commands that
205 you've entered on the
208 and then modify and/or execute the commands.
211 edit option for more information.
216 command can be used to display the current buffers, the backgrounded
217 screens, and the tags stack.
218 @IP{Extended Regular Expressions}
222 option causes Regular Expressions to be interpreted as as Extended
223 Regular Expressions, (i.e.@: @command{egrep}(1) style Regular Expressions).
224 @IP{File Name Completion}
226 It is possible to do file name completion and file name displays when
227 entering commands on the
232 option for more information.
235 Changes made during an edit session may be rolled backward and forward.
238 command immediately after a
240 command continues either forward or backward depending on whether the
242 command was an undo or a redo.
243 @IP{Left-right scrolling}
249 to do left-right screen scrolling, instead of the traditional
252 @IP{Message Catalogs}
254 It is possible to display informational and error messages in different
255 languages by providing a catalog of messages.
259 @LI{catalog/README}for more information.
260 @IP{Incrementing numbers}
264 command increments or decrements the number referenced by the cursor.
269 command edits the previous file from the argument list.
270 @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 @comment @IP{Shell screens}
285 @comment @CO{:sc[ript] [file ...]}
286 @comment command runs a shell in the screen.
287 @comment Editing is unchanged, with the exception that a \fC<carriage-return>\fP
288 @comment enters the current line (stripped of any prompt) as input to the
302 mode) commands divide the screen into multiple editing regions and
303 then perform their normal function in a new screen area.
306 command rotates between the foreground screens.
309 command can be used to grow or shrink a particular screen.
312 Tags are now maintained in a stack.
315 command returns to the previous tag location.
318 command returns to the most recent tag location by default, or,
319 optionally to a specific tag number in the tag stack,
320 or the most recent tag from a specified file.
323 command can be used to list the tags stack.
326 command returns to the top of the tag stack.
327 @IP{Usage information}
333 commands provide usage information for all of the
337 commands by default, or, optionally, for a specific command or key.
342 command searches for the word referenced by the cursor.
344 @chapter Startup Information
347 interprets one of two possible environmental variables and reads up to
348 three of five possible files during startup.
349 The variables and files are expected to contain
354 In addition, they are interpreted
356 the file to be edited is read, and therefore many
358 commands may not be used.
359 Generally, any command that requires output to the screen or that
360 needs a file upon which to operate, will cause an error if included
361 in a startup file or environmental variable.
365 command set supported by
367 is a superset of the command set supported by historical implementations of
370 can use the startup files created for the historical implementations,
371 but the converse may not be true.
375 (the historic - option)
376 is specified, or if standard input is redirected from a file,
377 all environmental variables and startup files are ignored.
379 Otherwise, startup files and environmental variables are handled
380 in the following order:
384 @LI{/etc/vi.exrc}is read,
385 as long as it is owned by root or the effective user ID of the user.
387 The environmental variable
388 @LI{NEXINIT}(or the variable
391 @LI{NEXINIT}is not set) is interpreted.
395 @LI{EXINIT}was set, and the
396 @LI{HOME}environmental variable is set, the file
397 @LI{$HOME/.nexrc}(or the file
400 @LI{$HOME/.nexrc}does not exist) is read,
401 as long as the effective user ID of the user is root or is the same as
402 the owner of the file.
404 When the $HOME directory is being used for both
406 and an historic implementation of
408 a possible solution is to put
410 specific commands in the
411 @LI{.nexrc}file, along with a
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
419 @LI{.nexrc}(or the file
422 @LI{.nexrc}does not exist) is read, as long as the effective user ID of the user
423 is the same as the owner of the file.
426 No startup file is read if it is writable by anyone other than its owner.
428 It is not an error for any of the startup environmental variables or files
431 Once all environmental variables are interpreted,
432 and all startup files are read,
433 the first file to be edited is read in (or a temporary file is created).
434 Then, any commands specified using the
436 option are executed, in the context of that file.
439 There is no recovery program for
444 Recovery files are created readable and writable by the owner only.
445 Users may recover any file which they can read,
446 and the superuser may recover any edit session.
448 Edit sessions are backed by files in the directory named by the
450 option (the directory
451 @LI{/var/tmp/vi.recover}by default), and are named
455 is a number related to the process ID.
456 When a file is first modified,
457 a second recovery file containing an email message for the user is created,
462 is associated with the process ID.
463 Both files are removed at the end of a normal edit session,
464 but will remain if the edit session is abnormally terminated
472 option may be set in either the user's or system's startup information,
473 changing the recovery directory.
474 (Note, however, that if a memory based file system is used as the backup
475 directory, each system reboot will delete all of the recovery files!
476 The same caution applies to directories such as
477 @LI{/tmp}which are cleared of their contents by a system reboot, or
478 @LI{/usr/tmp}which is periodically cleared of old files on many systems.)
480 The recovery directory should be owned by root, or at least by a pseudo-user.
481 In addition, if directory
483 semantics are available, the directory should have the sticky-bit
484 set so that files may only be removed by their owners.
485 The recovery directory must be read, write, and executable by any user,
488 If the recovery directory does not exist,
490 will attempt to create it.
491 This can result in the recovery directory being owned by a normal user,
492 which means that that user will be able to remove other user's recovery
494 This is annoying, but is not a security issue as the user cannot
495 otherwise access or modify the files.
497 The recovery file has all of the necessary information in it to enable the
498 user to recover the edit session.
499 In addition, it has all of the necessary email headers for
501 When the system is rebooted, all of the files in
502 @LI{/var/tmp/vi.recover}named
504 should be sent to their owners, by email, using the
508 (or a similar mechanism in other mailers).
511 receives a hangup (SIGHUP) signal, or the user executes the
516 will automatically email the recovery information to the user.
518 If your system does not have the
520 utility (or a mailer program which supports its interface)
522 @LI{nvi/common/recover.c}will have to be modified to use your local mail delivery programs.
525 is changed to use another mailer,
526 it is important to remember that the owner of the file given to
529 user, so nothing in the file should be trusted as it may have been
530 modified in an effort to compromise the system.
532 Finally, the owner execute bit is set on backup files when they are
533 created, and unset when they are first modified, e.g. backup files
534 that have no associated email recovery file will have this bit set.
535 (There is also a small window where empty files can be created and
536 not yet have this bit set.
537 This is due to the method in which the files are created.)
538 Such files should be deleted when the system reboots.
540 A simple way to do this cleanup is to run the Bourne shell script
543 @LI{/etc/rc.local}(or other system startup) file.
544 The script should work with the historic Bourne shell,
545 a POSIX 1003.2 shell or the Korn shell.
548 script is installed as part of the
550 installation process.
552 Consult the manual page for details on recovering preserved or
553 aborted editing sessions.
554 @chapter Sizing the Screen
556 The size of the screen can be set in a number of ways.
558 takes the following steps until values are obtained for both the
559 number of rows and number of columns in the screen.
562 If the environmental variable
564 it is used to specify the number of rows in the screen.
566 If the environmental variable
568 it is used to specify the number of columns in the screen.
572 is attempted on the standard error file descriptor.
574 The termcap entry (or terminfo entry on System V machines)
581 The number of rows is set to 24, and the number of columns is set to 80.
584 If a window change size signal (SIGWINCH) is received,
585 the new window size is retrieved using the TIOCGWINSZ
587 call, and all other information is ignored.
588 @chapter Character Display
594 printable characters as defined by
596 are displayed using the local character set.
598 Non-printable characters, for which
600 returns true, and which are less than octal \e040,
601 are displayed as the string
604 @LI{<character>}is the character that is the original character's value offset from the
607 For example, the octal character \e001 is displayed as
611 returns true for the octal character \e177,
612 it is displayed as the string
614 All other characters are displayed as either hexadecimal values,
616 @QT{0x<high-halfbyte> ... 0x<low-halfbyte>},
617 or as octal values, in the form
618 @QT{\e<high-one-or-two-bits> ... \e<low-three-bits>}.
619 The display of unknown characters is based on the value of the
625 command mode, the cursor is always positioned on the last column of
626 characters which take up more than one column on the screen.
629 text input mode, the cursor is positioned on the first column of
630 characters which take up more than one column on the screen.
631 @chapter Multiple Screens
634 supports multiple screens by dividing the window into regions.
635 It also supports stacks of screens by permitting the user to change
636 the set of screens that are currently displayed.
650 commands divide the current screen into two regions of approximately
651 equal size and then perform their usual action in a new screen area.
652 If the cursor is in the lower half of the screen, the screen will split
653 up, i.e.@: the new screen will be above the old one.
654 If the cursor is in the upper half of the screen, the new screen will be
657 When more than one screen is editing a file, changes in any screen are
658 reflected in all other screens editing the same file.
659 Exiting a screen without saving any changes (or explicitly discarding
660 them) is permitted until the last screen editing the file is exited,
661 at which time the changes must be saved or discarded.
665 command permits resizing of individual screens.
666 Screens may be grown, shrunk or set to an absolute number of rows.
670 command is used to switch between screens.
673 moves to the next lower screen in the window, or to the first screen
674 in the window if there are no lower screens.
681 The screen disappears from the window,
682 and the rows it occupied are taken over by a neighboring screen.
683 It is an error to attempt to background the only screen in the window.
687 command displays the names of the files associated with the current
688 backgrounded screens in the window.
692 command moves the specified screen from the list of backgrounded screens
694 If no file argument is specified, the first screen on the list is
697 foregrounding consists of backgrounding the current screen,
698 and replacing its space in the window with the foregrounded screen.
700 Capitalizing the first letter of the command, i.e.@:
702 will foreground the backgrounded screen in a new screen instead of
703 swapping it with the current screen.
705 If the last foregrounded screen in the window is exited,
706 and there are backgrounded screens,
707 the first screen on the list of backgrounded screens takes over the window.
708 @chapter Tags, Tag Stacks, and Cscope
711 supports the historic
719 These commands change the current file context to a new location,
720 based on information found in the
722 If you are unfamiliar with these commands,
723 you should review their description in the
727 commands section of this manual.
728 For additional information on tags files,
729 see the discussion of the
731 edit option and the system
737 supports the notion of
744 command returns the user to the previous context, i.e.,
745 the last place from which a
750 These three commands provide the basic functionality which allows you
753 to review source code in a structured manner.
756 also provides two other basic
758 commands for tag support:
764 command is identical to the
767 with the additional functionality that you may specify that modifications
768 to the current file are to be discarded.
769 This cannot be done using the
774 command discards all of the contexts that have been pushed onto the tag
775 stack, returning to the context from which the first
783 tags file format supports only a single location per tag,
784 normally the function declaration or structure or string definition.
785 More sophisticated source code tools often provide multiple locations
787 a list of the places from which a function is called or a string
789 An example of this functionality is the System V source code tool,
793 creates a database of information on source code files,
794 and supports a query language for that information as described in the
798 contains an interface to the
800 query language which permits you to query
802 and then sequentially step through the locations in the sources files which
807 commands which support this ability to step through multiple locations.
816 command moves to the next location for the current tag.
819 command moves to the previous location for the current tag.
824 command discussion in the
826 commands section of this manual for more information.)
827 At any time during this sequential walk,
833 commands to move to a new tag context, and then use the
837 commands to return and continue stepping through the locations for this
839 This is similar to the previous model of a simple tag stack,
840 except that each entry in the tag stack may have more than one file context
843 Although there is no widely distributed version of
845 that creates tags files with multiple locations per tag,
847 has been written to understand the obvious extension to the historic
848 tags file format, i.e., more than a single line in the tags file with
849 the same initial tag name.
850 If you wish to extend your
852 implementation or other tool with which you build tags files,
853 this extension should be simple and will require no changes to
860 interface is based on the new
864 which has five subcommands:
873 itself has eight subcommands:
885 @IP{cs[cope] a[dd] file}
889 command attaches to the specified
892 The file name is expanded using the standard filename expansions.
895 is a directory, the file
897 in that directory is used as the database.
901 attaches to a new database,
904 queries will be asked of that database.
905 The result of any single query is the collection of response to the query
906 from all of the attached databases.
910 environmental variable is set when
913 it is expected to be a <colon> or <blank>-separated list of
915 databases or directories containing
917 databases, to which the user wishes to attach.
918 @IP{:cs[cope] f[ind] c|d|e|f|g|i|s|t buffer|pattern}
930 databases for the pattern.
931 If the pattern is a double-quote character followed by a valid buffer
933 @LI{}"<character>" ),
934 then the contents of the named buffer are used as the pattern.
935 Otherwise, the pattern is a Regular Expression.
939 command pushes the current location onto the tags stack,
940 and switches to the first location resulting from the query,
941 if the query returned at least one result.
943 File names returned by the
945 query, if not absolute paths, are searched for relative to the directory
949 In addition, if the file
951 appears in the same directory as the
954 it is expected to contain a colon-separated list of directory names
955 where files referenced by its associated
957 database may be found.
961 subcommand is one of the following:
964 Find callers of the name.
966 Find all function calls made from name.
970 Find files with name as substring.
972 Find definition of name.
974 Find files #including name.
976 Find all uses of name.
978 Find assignments to name.
980 @IP{:cs[cope] h[elp] [command]}
985 or optionally list usage help for any single
988 @IP{:display c[onnections]}
994 is currently connected.
995 @IP{:cs[cope] k[ill] #}
997 Disconnect from a specific
1000 The connection number is the one displayed by the
1002 @CO{display connections}
1004 @IP{:cs[cope] r[eset]}
1006 Disconnect from all attached
1011 Cscope is not freely redistributable software,
1012 but is fairly inexpensive and easily available.
1013 To purchase a copy of
1015 see http://www.att.com/ssg/products/toolchest.html.
1016 @chapter Regular Expressions and Replacement Strings
1018 Regular expressions are used in line addresses,
1019 as the first part of the
1025 commands, and in search patterns.
1027 The regular expressions supported by
1029 are, by default, the Basic Regular Expressions (BRE's) described in the
1030 IEEE POSIX Standard 1003.2.
1033 option causes all regular expressions to be interpreted as the Extended
1034 Regular Expressions (ERE's) described by the same standard.
1037 for more information.)
1038 Generally speaking, BRE's are the Regular Expressions found in
1042 and ERE's are the Regular Expressions found in
1045 The following is not intended to provide a description of Regular
1047 The information here only describes strings and characters which
1048 have special meanings in the
1051 or options which change the meanings of characters that normally
1052 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
1080 set, the only characters with special meanings are a
1082 character at the beginning of an RE, a
1084 character at the end of an RE, and the escaping character
1092 are treated as ordinary characters unless preceded by a
1096 they regain their special meaning.
1098 Replacement strings are the second part of a
1110 set) in the replacement string stands for the text matched by the RE
1111 that is being replaced.
1120 set) stands for the replacement part of the previous
1123 It is only valid after a
1125 command has been performed.
1131 is an integer value from 1 to 9, stands for the text matched by
1132 the portion of the RE enclosed in the
1134 set of escaped parentheses, e.g.
1139 @QT{s/abc\e(.*\e)def/\e1/}
1144 from the matched pattern.
1152 can be used to modify the case of elements in the replacement string.
1155 causes the next character to be converted to lowercase;
1158 behaves similarly, but converts to uppercase
1160 @LI{s/abc/\eU&/}replaces the string
1165 causes characters up to the end of the string or the next occurrence
1170 to be converted to lowercase;
1173 behaves similarly, but converts to uppercase.
1175 If the entire replacement pattern is
1177 then the last replacement pattern is used again.
1182 @LI{<control-M>}into the replacement string will cause
1183 the matched line to be split into two lines at that point.
1185 @LI{<control-M>}will be discarded.)
1186 @chapter Scripting Languages
1190 editor currently supports two scripting languages, Tcl/Tk and Perl.
1191 (Note that Perl4 isn't sufficient, and that the Perl5 used must be
1192 version 5.002 or later.
1195 section for more information.
1197 The scripting language interface is still being worked on,
1198 therefore the following information is probably incomplete,
1199 probably wrong in cases, and likely to change.
1202 @LI{tcl_api}source directories for more information.
1203 As a quick reference, the following function calls are provided for
1204 both the Perl and Tcl interfaces.
1205 The Perl interface uses a slightly different naming convention,
1206 e.g. ``viFindScreen'' is named ``VI::FindScreen''.
1208 @IP{viFindScreen file}
1211 @LI{screenId}associated with
1213 @IP{viAppendLine screenId lineNumber text}
1216 @LI{text}as a new line after line number
1220 @IP{viDelLine screenId lineNum}
1223 @LI{lineNumber}from the screen
1225 @IP{viGetLine screenId lineNumber}
1228 @LI{lineNumber}from the screen
1230 @IP{viInsertLine screenId lineNumber text}
1233 @LI{text}as a new line before line number
1234 @LI{lineNumber}in the screen
1236 @IP{viLastLine screenId}
1238 Return the line number of the last line in the screen
1240 @IP{viSetLine screenId lineNumber text}
1243 @LI{lineNumber}in the screen
1244 @LI{screenId}to match the specified
1246 @IP{viGetMark screenId mark}
1248 Return the current line and column for the specified
1249 @LI{mark}from the screen
1251 @IP{viSetMark screenId mark line column}
1254 @LI{mark}to be at line
1260 @IP{viGetCursor screenId}
1262 Return the current line and column for the cursor in the screen
1264 @IP{viSetCursor screenId line column}
1266 Set the cursor in the screen
1267 @LI{screenId}to the specified
1270 @IP{viMsg screenId text}
1272 Display the specified
1273 @LI{text}as a vi message in the screen
1275 @IP{viNewScreen screenId [file]}
1277 Create a new screen.
1278 @IP{viEndScreen screenId}
1282 @IP{viSwitchScreen screenId screenId}
1284 Switch from the screen
1285 @LI{screenId}to the screen
1287 @IP{viMapKey screenId key tclproc}
1290 @LI{key}in the screen
1291 @LI{screenId}to the Tcl procedure
1293 @IP{viUnmMapKey screenId key}
1296 @LI{key}in the screen
1297 @LI{screenId}@IP{viGetOpt screenId option}
1299 Return the value of the specified
1300 @LI{option}from the screen
1302 @IP{viSetOpt screenId command}
1304 Set one or more options in the screen
1307 @chapter General Editor Description
1314 the text of a file is read (or a temporary file is created),
1315 and then all editing changes happen within the context of the
1317 @emph{No changes affect the actual file until the file is written out},
1318 either using a write command or another command which is affected by the
1322 All files are locked (using the
1326 interfaces) during the edit session,
1327 to avoid inadvertently making modifications to multiple copies of the file.
1328 If a lock cannot be obtained for a file because it is locked by another
1329 process, the edit session is read-only (as if the
1333 flag had been specified).
1334 If a lock cannot be obtained for other reasons, the edit session will
1335 continue, but the file status information
1338 command) will reflect this fact.
1344 are modeful editors, i.e.@: they have two modes,
1349 The former is intended to permit you to enter commands which modifies
1350 already existing text.
1351 The latter is intended to permit you to enter new text.
1354 first starts running, it is in command mode, and usually displays a prompt
1357 option for more information).
1358 The prompt is a single colon
1361 There are three commands that switch
1363 into text input mode:
1368 Once in input mode, entering a line containing only a single period
1370 ends text input mode and returns to command mode,
1371 where the prompt is redisplayed.
1375 first starts running, it is in command mode as well.
1376 There are eleven commands that switch
1378 into text input mode:
1391 Once in input mode, entering an
1392 @LI{<escape>}character ends text input mode and returns to command mode.
1395 present three different interfaces to editing a file.
1397 presents a line oriented interface.
1399 presents a full screen display oriented interface,
1402 In addition, there is a third mode,
1404 which is line oriented,
1405 but supports cursor movement and editing within the displayed line,
1406 similarly to visual mode.
1407 Open mode is not yet implemented in
1410 The following words have special meanings in both the
1414 command descriptions:
1419 The interrupt character is used to interrupt the current operation.
1422 whatever character is set for the current terminal is used.
1423 @cindex "<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,
1432 @LI{<control-Q>}is used to mean literal next as well.
1433 @cindex "current pathname"
1434 @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 @cindex "alternate pathname"
1446 @IP{alternate pathname}
1448 The name of the last file name mentioned in an
1451 the previous current pathname if the last file mentioned
1452 becomes the current file.
1453 When the hash mark character
1455 appears in a file name entered as part of an
1457 command argument, it is replaced by the alternate pathname.
1460 character can be escaped by preceding it with a backslash.)
1464 One of a number of named areas for saving copies of text.
1465 Commands that change or delete text can save the changed or deleted
1466 text into a specific buffer, for later use, if the command allows
1470 command cannot save the changed text in a named buffer).
1471 Buffers are named with a single character, preceded by a double quote,
1477 without the double quote, e.g.
1481 (The double quote isn't necessary for
1483 because buffers names are denoted by their position in the command line.)
1484 Historic implementations of
1487 @LI{<character>}to the alphanumeric characters;
1489 permits the use of any character without another meaning in the position
1490 where a buffer name is expected.
1492 Buffers named by uppercase characters are the same as buffers
1493 named by lowercase characters, e.g. the buffer named by the
1496 is the same as the buffer named by the character
1498 with the exception that, if the buffer contents are being changed (as
1499 with a text deletion or
1502 command), the text is
1504 to the buffer, instead of replacing the current contents.
1506 The buffers named by the numeric characters (in English,
1511 If a region of text including characters from more than one line,
1512 or a single line of text specified by using a line-oriented motion,
1513 is changed or deleted in the file using the
1518 commands, a copy of the text is placed into the numeric buffer
1520 regardless of the user specifying another buffer in which to save it.
1521 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.
1533 @multitable {@CO{'<character>}} {@CO{AA}} {@CO{AA}} {@CO{AA}}
1534 @item @CO{<control-A>} @tab @CO{%} @tab @CO{(} @tab @CO{)}
1535 @item @CO{`<character>} @tab @CO{/} @tab @CO{?} @tab @CO{N}
1536 @item @CO{n} @tab @strong{@{} @tab @strong{@}}
1539 Before this copy is done, the previous contents of buffer
1541 are moved into buffer
1547 The contents of buffer
1552 text may be explicitly stored into the numeric buffers.
1553 In this case, the buffer rotation described above occurs before the
1554 replacement of the buffer's contents.
1555 The numeric buffers are only available in
1558 and are not accessible by
1560 in any way, although changed and deleted text is still stored there
1567 command synopsis shows both a
1570 they may be presented in any order.
1572 Finally, all buffers are either
1579 commands which store text into buffers are line oriented.
1582 commands which store text into buffers are line oriented,
1583 and some are character oriented; the description for each applicable
1585 command notes whether text copied into buffers using the command
1586 is line or character oriented.
1590 @CO{display buffers}
1591 displays the current orientation for each buffer.
1592 Generally, the only importance attached to this orientation is that
1593 if the buffer is subsequently inserted into the text, line oriented
1594 buffers create new lines for each of the lines they contain, and
1595 character oriented buffers create new lines for any lines
1597 than the first and last lines they contain.
1598 The first and last lines are inserted into the text at the current
1599 cursor position, becoming part of the current line.
1600 If there is more than one line in the buffer, however, the current
1601 line itself will be split.
1602 @cindex "unnamed buffer"
1605 The unnamed buffer is a text storage area which is used by commands
1606 that use or operate on a buffer when no buffer is specified by the user.
1607 If the command stores text into a buffer,
1608 the text is stored into the unnamed buffer even if a buffer is also
1609 specified by the user.
1610 It is not possible to append text to the unnamed buffer.
1611 If text is appended to a named buffer,
1612 the named buffer contains both the old and new text,
1613 while the unnamed buffer contains only the new text.
1614 There is no way to explicitly reference the unnamed buffer.
1616 Historically, the contents of the unnamed buffer were discarded by many
1617 different commands, even ones that didn't store text into it.
1619 never discards the contents of the unnamed buffer until new text
1624 The characters <tab> and <space>.
1625 @cindex "<carriage-return>"
1626 @IP{<carriage-return>}
1628 The character represented by an ASCII
1630 This character is almost always treated identically to a
1631 @LI{<newline>}character, but differs in that it can be escaped into the file text or
1636 The character represented by an ASCII
1638 This character is almost always treated identically to a
1639 @LI{<control-M>}character, but differs in that it cannot be escaped into the file text or
1642 @comment .oh 'Vi/Ex Reference (Vi Commands)''USD:13-%'
1643 @comment .eh 'USD:13-%''Vi/Ex Reference (Vi Commands)'
1644 @node Vi Commands,(dir),(dir),(dir)
1645 @include vi.cmd.texi
1646 @comment .oh 'Vi/Ex Reference''USD:13-%'
1647 @comment .eh 'USD:13-%''Vi/Ex Reference'
1648 @chapter Ex Addressing
1654 commands are executed from
1656 relates to the current line.
1657 In general, the current line is the last line affected by a command.
1658 The exact effect on the current line is discussed under the description
1660 When the file contains no lines, the current line is zero.
1662 Addresses are constructed by one or more of the following methods:
1667 refers to the current line.
1671 refers to the last line of the file.
1676 @LI{N}is a positive number, refers to the N-th line of the file.
1682 refers to the line marked with the name
1688 commands for more information on how to mark lines.)
1690 A regular expression (RE) enclosed by slashes
1693 and it refers to the first line found by searching forward from the line
1695 the current line toward the end of the file, and stopping at the
1696 first line containing a string matching the RE.
1697 (The trailing slash can be omitted at the end of the command line.)
1699 If no RE is specified, i.e.@: the pattern is
1701 the last RE used in any command is used in the search.
1705 option is set, the RE is handled as an extended RE, not a basic RE.
1708 option is set, the search wraps around to the beginning of the file
1709 and continues up to and including the current line, so that the entire
1714 is accepted for historic reasons,
1718 An RE enclosed in question marks
1720 addresses the first line found by searching backward from the line
1722 the current line, toward the beginning of the file and stopping at the
1723 first line containing a string matching the RE.
1724 (The trailing question mark can be omitted at the end of a command line.)
1726 If no RE is specified, i.e.@: the pattern is
1728 the last RE used in any command is used in the search.
1732 option is set, the RE is handled as an extended RE, not a basic RE.
1735 option is set, the search wraps around from the beginning of the file to
1736 the end of the file and continues up to and including the current line,
1737 so that the entire file is searched.
1741 is accepted for historic reasons, and is identical to
1744 An address followed by a plus sign
1748 followed by a number is an offset address and refers to the address
1749 plus (or minus) the indicated number of lines.
1750 If the address is omitted, the addition or subtraction is done with
1751 respect to the current line.
1757 followed by a number is an offset from the current line.
1763 An address ending with
1767 has 1 added to or subtracted from the address, respectively.
1768 As a consequence of this rule and of the previous rule, the address
1770 refers to the line preceding the current line.
1775 characters have a cumulative effect.
1778 refers to the current line plus 3.
1782 is equivalent to the address range
1787 commands require zero, one, or two addresses.
1788 It is an error to specify an address to a command which requires zero
1791 If the user provides more than the expected number of addresses to any
1793 command, the first addresses specified are discarded.
1796 prints lines 3 through 5, because the
1798 command only takes two addresses.
1800 The addresses in a range are separated from each other by a comma
1804 In the latter case, the current line
1806 is set to the first address, and only then is the second address calculated.
1807 This feature can be used to determine the starting line for forward and
1808 backward searches (see rules (5) and (6) above).
1809 The second address of any two-address sequence corresponds to a line that
1810 follows, in the file, the line corresponding to the first address.
1811 The first address must be less than or equal to the second address.
1812 The first address must be greater than or equal to the first line of the
1813 file, and the last address must be less than or equal to the last line
1815 @comment .oh 'Vi/Ex Reference (Ex Commands)''USD:13-%'
1816 @comment .eh 'USD:13-%''Vi/Ex Reference (Ex Commands)'
1817 @node Ex Commands,(dir),(dir),(dir)
1818 @include ex.cmd.texi
1819 @comment .oh 'Vi/Ex Reference (Options)''USD:13-%'
1820 @comment .eh 'USD:13-%''Vi/Ex Reference (Options)'
1821 @include set.opt.texi
1822 @comment .oh 'Vi/Ex Reference''USD:13-%'
1823 @comment .eh 'USD:13-%''Vi/Ex Reference'
1827 @comment Force the TOC to an odd page, in case it's a duplex printer.