2 @c $NetBSD: vi.texi,v 1.1.1.2 2008/05/18 14:31:04 aymeric Exp $
3 @setfilename vi.ref.info
8 @comment Copyright (c) 1994
9 @comment The Regents of the University of California. All rights reserved.
10 @comment Copyright (c) 1994, 1995, 1996
11 @comment Keith Bostic. All rights reserved.
13 @comment This document may not be republished without written permission from
14 @comment Keith Bostic.
16 @comment See the LICENSE file for redistribution information.
18 @comment Id: vi.texi,v 8.1 2001/08/18 20:43:50 skimo Exp (Berkeley) Date: 2001/08/18 20:43:50
21 @node Top,(dir),(dir),(dir)
28 @center @titlefont{Vi/Ex Reference Manual}
30 @center @emph{Keith Bostic}
32 @center Computer Science Division
33 @center Department of Electrical Engineering and Computer Science
34 @center University of California, Berkeley
35 @center Berkeley, California 94720
37 @center @emph{Sven Verdoolaege}
41 @center @emph{Abstract}
43 This document is the reference guide for the 4.4BSD
46 which are implementations of the historic Berkeley
49 @vskip 0pt plus 1filll
50 Copyright @copyright{} 1991, 1992, 1993, 1994@*
51 @hskip 2cm The Regents of the University of California. All Rights Reserved.@*
52 Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996@*
53 @hskip 2cm Keith Bostic. All Rights Reserved.@*
54 Copyright @copyright{} 2001@*
55 @hskip 2cm Sven Verdoolaege. All Rights Reserved.@*
57 @center@emph{Acknowledgements}
60 Bruce Englar encouraged the early development of the historic
63 Peter Kessler helped bring sanity to version 2's command layout.
64 Bill Joy wrote versions 1 and 2.0 through 2.7,
65 and created the framework that users see in the present editor.
66 Mark Horton added macros and other features and made
68 work on a large number of terminals and Unix systems.
71 is originally derived from software contributed to the University of
72 California, Berkeley by Steve Kirkendall, the author of the
77 IEEE Standard Portable Operating System Interface for Computer
78 Environments (POSIX) 1003.2 style Regular Expression support was
79 done by Henry Spencer.
81 The curses library was originally done by Ken Arnold.
82 Scrolling and reworking for
84 was done by Elan Amir.
86 George Neville-Neil added the Tcl interpreter,
87 and Sven Verdoolaege added the Perl interpreter.
89 Rob Mayoff added Cscope support.
91 The Institute of Electrical and Electronics Engineers has
92 given us permission to reprint portions of their documentation.
93 Portions of this document are reprinted and reproduced from
94 IEEE Std 1003.2-1992, IEEE Standard Portable Operating
95 System Interface for Computer Environments (POSIX),
96 copyright 1992 by the Institute of Electrical and Electronics
99 The financial support of UUNET Communications Services is gratefully
106 is a screen oriented text editor.
108 is a line-oriented text editor.
112 are different interfaces to the same program,
113 and it is possible to switch back and forth during an edit session.
115 is the equivalent of using the
117 (read-only) option of
120 This reference manual is the one provided with the
126 are intended as bug-for-bug compatible replacements for the original
127 Fourth Berkeley Software Distribution (4BSD)
130 This reference manual is accompanied by a traditional-style manual page.
131 That manual page describes the functionality found in
133 in far less detail than the description here.
134 In addition, it describes the system interface to
136 e.g. command line options, session recovery, signals,
137 environmental variables, and similar things.
139 This reference is intended for users already familiar with
141 Anyone else should almost certainly read a good tutorial on the
143 If you are in an unfamiliar environment,
144 and you absolutely have to get work done immediately,
145 see the section entitled
148 It is probably enough to get you started.
150 There are a few features in
152 that are not found in historic versions of
154 Some of the more interesting of those features are briefly described
155 in the next section, entitled
156 @QB{Additional Features} .
157 For the rest of this document,
159 is used only when it is necessary to distinguish it from the historic
163 Future versions of this software will be periodically made available
164 by anonymous ftp, and can be retrieved from
165 @LI{ftp.cs.berkeley.edu},
168 @chapter Additional Features in Nex/Nvi
170 There are a few features in
172 that are not found in historic versions of
174 Some of the more interesting of these are as follows:
176 @IP{8-bit clean data, large lines, files}
179 will edit any format file.
180 Line lengths are limited by available memory,
181 and file sizes are limited by available disk space.
184 text input mode command
186 can insert any possible character value into the text.
187 @IP{Background and foreground screens}
191 command backgrounds the current screen, and the
193 command foregrounds backgrounded screens.
196 command can be used to list the background screens.
199 You can enter a normal editing window on the collected commands that
200 you've entered on the
203 and then modify and/or execute the commands.
206 edit option for more information.
211 command can be used to display the current buffers, the backgrounded
212 screens, and the tags stack.
213 @IP{Extended Regular Expressions}
217 option causes Regular Expressions to be interpreted as as Extended
218 Regular Expressions, (i.e.@: @command{egrep}(1) style Regular Expressions).
219 @IP{File Name Completion}
221 It is possible to do file name completion and file name displays when
222 entering commands on the
227 option for more information.
230 Changes made during an edit session may be rolled backward and forward.
233 command immediately after a
235 command continues either forward or backward depending on whether the
237 command was an undo or a redo.
238 @IP{Left-right scrolling}
244 to do left-right screen scrolling, instead of the traditional
247 @IP{Message Catalogs}
249 It is possible to display informational and error messages in different
250 languages by providing a catalog of messages.
254 @LI{catalog/README}for more information.
255 @IP{Incrementing numbers}
259 command increments or decrements the number referenced by the cursor.
264 command edits the previous file from the argument list.
265 @IP{Scripting languages}
272 commands execute Perl and Tcl/Tk commands, respectively,
273 on lines from the edit buffer.
275 @QB{Scripting Languages}
276 section and the specific commands for more information.
277 @comment @IP{Shell screens}
280 @comment @CO{:sc[ript] [file ...]}
281 @comment command runs a shell in the screen.
282 @comment Editing is unchanged, with the exception that a \fC<carriage-return>\fP
283 @comment enters the current line (stripped of any prompt) as input to the
297 mode) commands divide the screen into multiple editing regions and
298 then perform their normal function in a new screen area.
301 command rotates between the foreground screens.
304 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}
328 commands provide usage information for all of the
332 commands by default, or, optionally, for a specific command or key.
337 command searches for the word referenced by the cursor.
339 @chapter Startup Information
342 interprets one of two possible environmental variables and reads up to
343 three of five possible files during startup.
344 The variables and files are expected to contain
349 In addition, they are interpreted
351 the file to be edited is read, and therefore many
353 commands may not be used.
354 Generally, any command that requires output to the screen or that
355 needs a file upon which to operate, will cause an error if included
356 in a startup file or environmental variable.
360 command set supported by
362 is a superset of the command set supported by historical implementations of
365 can use the startup files created for the historical implementations,
366 but the converse may not be true.
370 (the historic - option)
371 is specified, or if standard input is redirected from a file,
372 all environmental variables and startup files are ignored.
374 Otherwise, startup files and environmental variables are handled
375 in the following order:
379 @LI{/etc/vi.exrc}is read,
380 as long as it is owned by root or the effective user ID of the user.
382 The environmental variable
383 @LI{NEXINIT}(or the variable
386 @LI{NEXINIT}is not set) is interpreted.
390 @LI{EXINIT}was set, and the
391 @LI{HOME}environmental variable is set, the file
392 @LI{$HOME/.nexrc}(or the file
395 @LI{$HOME/.nexrc}does not exist) is read,
396 as long as the effective user ID of the user is root or is the same as
397 the owner of the file.
399 When the $HOME directory is being used for both
401 and an historic implementation of
403 a possible solution is to put
405 specific commands in the
406 @LI{.nexrc}file, along with a
407 @CO{:source $HOME/.exrc}
408 command to read in the commands common to both implementations.
412 option was turned on by one of the previous startup information
414 @LI{.nexrc}(or the file
417 @LI{.nexrc}does not exist) is read, as long as the effective user ID of the user
418 is the same as the owner of the file.
421 No startup file is read if it is writable by anyone other than its owner.
423 It is not an error for any of the startup environmental variables or files
426 Once all environmental variables are interpreted,
427 and all startup files are read,
428 the first file to be edited is read in (or a temporary file is created).
429 Then, any commands specified using the
431 option are executed, in the context of that file.
434 There is no recovery program for
439 Recovery files are created readable and writable by the owner only.
440 Users may recover any file which they can read,
441 and the superuser may recover any edit session.
443 Edit sessions are backed by files in the directory named by the
445 option (the directory
446 @LI{/var/tmp/vi.recover}by default), and are named
450 is a number related to the process ID.
451 When a file is first modified,
452 a second recovery file containing an email message for the user is created,
457 is associated with the process ID.
458 Both files are removed at the end of a normal edit session,
459 but will remain if the edit session is abnormally terminated
467 option may be set in either the user's or system's startup information,
468 changing the recovery directory.
469 (Note, however, that if a memory based file system is used as the backup
470 directory, each system reboot will delete all of the recovery files!
471 The same caution applies to directories such as
472 @LI{/tmp}which are cleared of their contents by a system reboot, or
473 @LI{/usr/tmp}which is periodically cleared of old files on many systems.)
475 The recovery directory should be owned by root, or at least by a pseudo-user.
476 In addition, if directory
478 semantics are available, the directory should have the sticky-bit
479 set so that files may only be removed by their owners.
480 The recovery directory must be read, write, and executable by any user,
483 If the recovery directory does not exist,
485 will attempt to create it.
486 This can result in the recovery directory being owned by a normal user,
487 which means that that user will be able to remove other user's recovery
489 This is annoying, but is not a security issue as the user cannot
490 otherwise access or modify the files.
492 The recovery file has all of the necessary information in it to enable the
493 user to recover the edit session.
494 In addition, it has all of the necessary email headers for
496 When the system is rebooted, all of the files in
497 @LI{/var/tmp/vi.recover}named
499 should be sent to their owners, by email, using the
503 (or a similar mechanism in other mailers).
506 receives a hangup (SIGHUP) signal, or the user executes the
511 will automatically email the recovery information to the user.
513 If your system does not have the
515 utility (or a mailer program which supports its interface)
517 @LI{nvi/common/recover.c}will have to be modified to use your local mail delivery programs.
520 is changed to use another mailer,
521 it is important to remember that the owner of the file given to
524 user, so nothing in the file should be trusted as it may have been
525 modified in an effort to compromise the system.
527 Finally, the owner execute bit is set on backup files when they are
528 created, and unset when they are first modified, e.g. backup files
529 that have no associated email recovery file will have this bit set.
530 (There is also a small window where empty files can be created and
531 not yet have this bit set.
532 This is due to the method in which the files are created.)
533 Such files should be deleted when the system reboots.
535 A simple way to do this cleanup is to run the Bourne shell script
538 @LI{/etc/rc.local}(or other system startup) file.
539 The script should work with the historic Bourne shell,
540 a POSIX 1003.2 shell or the Korn shell.
543 script is installed as part of the
545 installation process.
547 Consult the manual page for details on recovering preserved or
548 aborted editing sessions.
549 @chapter Sizing the Screen
551 The size of the screen can be set in a number of ways.
553 takes the following steps until values are obtained for both the
554 number of rows and number of columns in the screen.
557 If the environmental variable
559 it is used to specify the number of rows in the screen.
561 If the environmental variable
563 it is used to specify the number of columns in the screen.
567 is attempted on the standard error file descriptor.
569 The termcap entry (or terminfo entry on System V machines)
576 The number of rows is set to 24, and the number of columns is set to 80.
579 If a window change size signal (SIGWINCH) is received,
580 the new window size is retrieved using the TIOCGWINSZ
582 call, and all other information is ignored.
583 @chapter Character Display
589 printable characters as defined by
591 are displayed using the local character set.
593 Non-printable characters, for which
595 returns true, and which are less than octal \e040,
596 are displayed as the string
599 @LI{<character>}is the character that is the original character's value offset from the
602 For example, the octal character \e001 is displayed as
606 returns true for the octal character \e177,
607 it is displayed as the string
609 All other characters are displayed as either hexadecimal values,
611 @QT{0x<high-halfbyte> ... 0x<low-halfbyte>},
612 or as octal values, in the form
613 @QT{\e<high-one-or-two-bits> ... \e<low-three-bits>}.
614 The display of unknown characters is based on the value of the
620 command mode, the cursor is always positioned on the last column of
621 characters which take up more than one column on the screen.
624 text input mode, the cursor is positioned on the first column of
625 characters which take up more than one column on the screen.
626 @chapter Multiple Screens
629 supports multiple screens by dividing the window into regions.
630 It also supports stacks of screens by permitting the user to change
631 the set of screens that are currently displayed.
645 commands divide the current screen into two regions of approximately
646 equal size and then perform their usual action in a new screen area.
647 If the cursor is in the lower half of the screen, the screen will split
648 up, i.e.@: the new screen will be above the old one.
649 If the cursor is in the upper half of the screen, the new screen will be
652 When more than one screen is editing a file, changes in any screen are
653 reflected in all other screens editing the same file.
654 Exiting a screen without saving any changes (or explicitly discarding
655 them) is permitted until the last screen editing the file is exited,
656 at which time the changes must be saved or discarded.
660 command permits resizing of individual screens.
661 Screens may be grown, shrunk or set to an absolute number of rows.
665 command is used to switch between screens.
668 moves to the next lower screen in the window, or to the first screen
669 in the window if there are no lower screens.
676 The screen disappears from the window,
677 and the rows it occupied are taken over by a neighboring screen.
678 It is an error to attempt to background the only screen in the window.
682 command displays the names of the files associated with the current
683 backgrounded screens in the window.
687 command moves the specified screen from the list of backgrounded screens
689 If no file argument is specified, the first screen on the list is
692 foregrounding consists of backgrounding the current screen,
693 and replacing its space in the window with the foregrounded screen.
695 Capitalizing the first letter of the command, i.e.@:
697 will foreground the backgrounded screen in a new screen instead of
698 swapping it with the current screen.
700 If the last foregrounded screen in the window is exited,
701 and there are backgrounded screens,
702 the first screen on the list of backgrounded screens takes over the window.
703 @chapter Tags, Tag Stacks, and Cscope
706 supports the historic
714 These commands change the current file context to a new location,
715 based on information found in the
717 If you are unfamiliar with these commands,
718 you should review their description in the
722 commands section of this manual.
723 For additional information on tags files,
724 see the discussion of the
726 edit option and the system
732 supports the notion of
739 command returns the user to the previous context, i.e.,
740 the last place from which a
745 These three commands provide the basic functionality which allows you
748 to review source code in a structured manner.
751 also provides two other basic
753 commands for tag support:
759 command is identical to the
762 with the additional functionality that you may specify that modifications
763 to the current file are to be discarded.
764 This cannot be done using the
769 command discards all of the contexts that have been pushed onto the tag
770 stack, returning to the context from which the first
778 tags file format supports only a single location per tag,
779 normally the function declaration or structure or string definition.
780 More sophisticated source code tools often provide multiple locations
782 a list of the places from which a function is called or a string
784 An example of this functionality is the System V source code tool,
788 creates a database of information on source code files,
789 and supports a query language for that information as described in the
793 contains an interface to the
795 query language which permits you to query
797 and then sequentially step through the locations in the sources files which
802 commands which support this ability to step through multiple locations.
811 command moves to the next location for the current tag.
814 command moves to the previous location for the current tag.
819 command discussion in the
821 commands section of this manual for more information.)
822 At any time during this sequential walk,
828 commands to move to a new tag context, and then use the
832 commands to return and continue stepping through the locations for this
834 This is similar to the previous model of a simple tag stack,
835 except that each entry in the tag stack may have more than one file context
838 Although there is no widely distributed version of
840 that creates tags files with multiple locations per tag,
842 has been written to understand the obvious extension to the historic
843 tags file format, i.e., more than a single line in the tags file with
844 the same initial tag name.
845 If you wish to extend your
847 implementation or other tool with which you build tags files,
848 this extension should be simple and will require no changes to
855 interface is based on the new
859 which has five subcommands:
868 itself has eight subcommands:
880 @IP{cs[cope] a[dd] file}
884 command attaches to the specified
887 The file name is expanded using the standard filename expansions.
890 is a directory, the file
892 in that directory is used as the database.
896 attaches to a new database,
899 queries will be asked of that database.
900 The result of any single query is the collection of response to the query
901 from all of the attached databases.
905 environmental variable is set when
908 it is expected to be a <colon> or <blank>-separated list of
910 databases or directories containing
912 databases, to which the user wishes to attach.
913 @IP{:cs[cope] f[ind] c|d|e|f|g|i|s|t buffer|pattern}
925 databases for the pattern.
926 If the pattern is a double-quote character followed by a valid buffer
928 @LI{}"<character>" ),
929 then the contents of the named buffer are used as the pattern.
930 Otherwise, the pattern is a Regular Expression.
934 command pushes the current location onto the tags stack,
935 and switches to the first location resulting from the query,
936 if the query returned at least one result.
938 File names returned by the
940 query, if not absolute paths, are searched for relative to the directory
944 In addition, if the file
946 appears in the same directory as the
949 it is expected to contain a colon-separated list of directory names
950 where files referenced by its associated
952 database may be found.
956 subcommand is one of the following:
959 Find callers of the name.
961 Find all function calls made from name.
965 Find files with name as substring.
967 Find definition of name.
969 Find files #including name.
971 Find all uses of name.
973 Find assignments to name.
975 @IP{:cs[cope] h[elp] [command]}
980 or optionally list usage help for any single
983 @IP{:display c[onnections]}
989 is currently connected.
990 @IP{:cs[cope] k[ill] #}
992 Disconnect from a specific
995 The connection number is the one displayed by the
997 @CO{display connections}
999 @IP{:cs[cope] r[eset]}
1001 Disconnect from all attached
1006 Cscope is not freely redistributable software,
1007 but is fairly inexpensive and easily available.
1008 To purchase a copy of
1010 see http://www.att.com/ssg/products/toolchest.html.
1011 @chapter Regular Expressions and Replacement Strings
1013 Regular expressions are used in line addresses,
1014 as the first part of the
1020 commands, and in search patterns.
1022 The regular expressions supported by
1024 are, by default, the Basic Regular Expressions (BRE's) described in the
1025 IEEE POSIX Standard 1003.2.
1028 option causes all regular expressions to be interpreted as the Extended
1029 Regular Expressions (ERE's) described by the same standard.
1032 for more information.)
1033 Generally speaking, BRE's are the Regular Expressions found in
1037 and ERE's are the Regular Expressions found in
1040 The following is not intended to provide a description of Regular
1042 The information here only describes strings and characters which
1043 have special meanings in the
1046 or options which change the meanings of characters that normally
1047 have special meanings in RE's.
1054 is equivalent to the last RE used.
1058 matches the beginning of a word.
1062 matches the end of a word.
1066 matches the replacement part of the last
1075 set, the only characters with special meanings are a
1077 character at the beginning of an RE, a
1079 character at the end of an RE, and the escaping character
1087 are treated as ordinary characters unless preceded by a
1091 they regain their special meaning.
1093 Replacement strings are the second part of a
1105 set) in the replacement string stands for the text matched by the RE
1106 that is being replaced.
1115 set) stands for the replacement part of the previous
1118 It is only valid after a
1120 command has been performed.
1126 is an integer value from 1 to 9, stands for the text matched by
1127 the portion of the RE enclosed in the
1129 set of escaped parentheses, e.g.
1134 @QT{s/abc\e(.*\e)def/\e1/}
1139 from the matched pattern.
1147 can be used to modify the case of elements in the replacement string.
1150 causes the next character to be converted to lowercase;
1153 behaves similarly, but converts to uppercase
1155 @LI{s/abc/\eU&/}replaces the string
1160 causes characters up to the end of the string or the next occurrence
1165 to be converted to lowercase;
1168 behaves similarly, but converts to uppercase.
1170 If the entire replacement pattern is
1172 then the last replacement pattern is used again.
1177 @LI{<control-M>}into the replacement string will cause
1178 the matched line to be split into two lines at that point.
1180 @LI{<control-M>}will be discarded.)
1181 @chapter Scripting Languages
1185 editor currently supports two scripting languages, Tcl/Tk and Perl.
1186 (Note that Perl4 isn't sufficient, and that the Perl5 used must be
1187 version 5.002 or later.
1190 section for more information.
1192 The scripting language interface is still being worked on,
1193 therefore the following information is probably incomplete,
1194 probably wrong in cases, and likely to change.
1197 @LI{tcl_api}source directories for more information.
1198 As a quick reference, the following function calls are provided for
1199 both the Perl and Tcl interfaces.
1200 The Perl interface uses a slightly different naming convention,
1201 e.g. ``viFindScreen'' is named ``VI::FindScreen''.
1203 @IP{viFindScreen file}
1206 @LI{screenId}associated with
1208 @IP{viAppendLine screenId lineNumber text}
1211 @LI{text}as a new line after line number
1215 @IP{viDelLine screenId lineNum}
1218 @LI{lineNumber}from the screen
1220 @IP{viGetLine screenId lineNumber}
1223 @LI{lineNumber}from the screen
1225 @IP{viInsertLine screenId lineNumber text}
1228 @LI{text}as a new line before line number
1229 @LI{lineNumber}in the screen
1231 @IP{viLastLine screenId}
1233 Return the line number of the last line in the screen
1235 @IP{viSetLine screenId lineNumber text}
1238 @LI{lineNumber}in the screen
1239 @LI{screenId}to match the specified
1241 @IP{viGetMark screenId mark}
1243 Return the current line and column for the specified
1244 @LI{mark}from the screen
1246 @IP{viSetMark screenId mark line column}
1249 @LI{mark}to be at line
1255 @IP{viGetCursor screenId}
1257 Return the current line and column for the cursor in the screen
1259 @IP{viSetCursor screenId line column}
1261 Set the cursor in the screen
1262 @LI{screenId}to the specified
1265 @IP{viMsg screenId text}
1267 Display the specified
1268 @LI{text}as a vi message in the screen
1270 @IP{viNewScreen screenId [file]}
1272 Create a new screen.
1273 @IP{viEndScreen screenId}
1277 @IP{viSwitchScreen screenId screenId}
1279 Switch from the screen
1280 @LI{screenId}to the screen
1282 @IP{viMapKey screenId key tclproc}
1285 @LI{key}in the screen
1286 @LI{screenId}to the Tcl procedure
1288 @IP{viUnmMapKey screenId key}
1291 @LI{key}in the screen
1292 @LI{screenId}@IP{viGetOpt screenId option}
1294 Return the value of the specified
1295 @LI{option}from the screen
1297 @IP{viSetOpt screenId command}
1299 Set one or more options in the screen
1302 @chapter General Editor Description
1309 the text of a file is read (or a temporary file is created),
1310 and then all editing changes happen within the context of the
1312 @emph{No changes affect the actual file until the file is written out},
1313 either using a write command or another command which is affected by the
1317 All files are locked (using the
1321 interfaces) during the edit session,
1322 to avoid inadvertently making modifications to multiple copies of the file.
1323 If a lock cannot be obtained for a file because it is locked by another
1324 process, the edit session is read-only (as if the
1328 flag had been specified).
1329 If a lock cannot be obtained for other reasons, the edit session will
1330 continue, but the file status information
1333 command) will reflect this fact.
1339 are modeful editors, i.e.@: they have two modes,
1344 The former is intended to permit you to enter commands which modifies
1345 already existing text.
1346 The latter is intended to permit you to enter new text.
1349 first starts running, it is in command mode, and usually displays a prompt
1352 option for more information).
1353 The prompt is a single colon
1356 There are three commands that switch
1358 into text input mode:
1363 Once in input mode, entering a line containing only a single period
1365 ends text input mode and returns to command mode,
1366 where the prompt is redisplayed.
1370 first starts running, it is in command mode as well.
1371 There are eleven commands that switch
1373 into text input mode:
1386 Once in input mode, entering an
1387 @LI{<escape>}character ends text input mode and returns to command mode.
1390 present three different interfaces to editing a file.
1392 presents a line oriented interface.
1394 presents a full screen display oriented interface,
1397 In addition, there is a third mode,
1399 which is line oriented,
1400 but supports cursor movement and editing within the displayed line,
1401 similarly to visual mode.
1402 Open mode is not yet implemented in
1405 The following words have special meanings in both the
1409 command descriptions:
1414 The interrupt character is used to interrupt the current operation.
1417 whatever character is set for the current terminal is used.
1418 @cindex "<literal-next>"
1421 The literal next character is used to escape the subsequent character
1422 from any special meaning.
1423 This character is always
1425 If the terminal is not set up to do XON/XOFF flow control,
1427 @LI{<control-Q>}is used to mean literal next as well.
1428 @cindex "current pathname"
1429 @IP{current pathname}
1431 The pathname of the file currently being edited by vi.
1432 When the percent character
1434 appears in a file name entered as part of an
1436 command argument, it is replaced by the current pathname.
1439 character can be escaped by preceding it with a backslash.)
1440 @cindex "alternate pathname"
1441 @IP{alternate pathname}
1443 The name of the last file name mentioned in an
1446 the previous current pathname if the last file mentioned
1447 becomes the current file.
1448 When the hash mark character
1450 appears in a file name entered as part of an
1452 command argument, it is replaced by the alternate pathname.
1455 character can be escaped by preceding it with a backslash.)
1459 One of a number of named areas for saving copies of text.
1460 Commands that change or delete text can save the changed or deleted
1461 text into a specific buffer, for later use, if the command allows
1465 command cannot save the changed text in a named buffer).
1466 Buffers are named with a single character, preceded by a double quote,
1472 without the double quote, e.g.
1476 (The double quote isn't necessary for
1478 because buffers names are denoted by their position in the command line.)
1479 Historic implementations of
1482 @LI{<character>}to the alphanumeric characters;
1484 permits the use of any character without another meaning in the position
1485 where a buffer name is expected.
1487 Buffers named by uppercase characters are the same as buffers
1488 named by lowercase characters, e.g. the buffer named by the
1491 is the same as the buffer named by the character
1493 with the exception that, if the buffer contents are being changed (as
1494 with a text deletion or
1497 command), the text is
1499 to the buffer, instead of replacing the current contents.
1501 The buffers named by the numeric characters (in English,
1506 If a region of text including characters from more than one line,
1507 or a single line of text specified by using a line-oriented motion,
1508 is changed or deleted in the file using the
1513 commands, a copy of the text is placed into the numeric buffer
1515 regardless of the user specifying another buffer in which to save it.
1516 In addition, there are a few commands which, when used as a
1524 copy the specified region of text into the numeric buffers regardless
1525 of the region including characters from more than one line.
1528 @multitable {@CO{'<character>}} {@CO{AA}} {@CO{AA}} {@CO{AA}}
1529 @item @CO{<control-A>} @tab @CO{%} @tab @CO{(} @tab @CO{)}
1530 @item @CO{`<character>} @tab @CO{/} @tab @CO{?} @tab @CO{N}
1531 @item @CO{n} @tab @strong{@{} @tab @strong{@}}
1534 Before this copy is done, the previous contents of buffer
1536 are moved into buffer
1542 The contents of buffer
1547 text may be explicitly stored into the numeric buffers.
1548 In this case, the buffer rotation described above occurs before the
1549 replacement of the buffer's contents.
1550 The numeric buffers are only available in
1553 and are not accessible by
1555 in any way, although changed and deleted text is still stored there
1562 command synopsis shows both a
1565 they may be presented in any order.
1567 Finally, all buffers are either
1574 commands which store text into buffers are line oriented.
1577 commands which store text into buffers are line oriented,
1578 and some are character oriented; the description for each applicable
1580 command notes whether text copied into buffers using the command
1581 is line or character oriented.
1585 @CO{display buffers}
1586 displays the current orientation for each buffer.
1587 Generally, the only importance attached to this orientation is that
1588 if the buffer is subsequently inserted into the text, line oriented
1589 buffers create new lines for each of the lines they contain, and
1590 character oriented buffers create new lines for any lines
1592 than the first and last lines they contain.
1593 The first and last lines are inserted into the text at the current
1594 cursor position, becoming part of the current line.
1595 If there is more than one line in the buffer, however, the current
1596 line itself will be split.
1597 @cindex "unnamed buffer"
1600 The unnamed buffer is a text storage area which is used by commands
1601 that use or operate on a buffer when no buffer is specified by the user.
1602 If the command stores text into a buffer,
1603 the text is stored into the unnamed buffer even if a buffer is also
1604 specified by the user.
1605 It is not possible to append text to the unnamed buffer.
1606 If text is appended to a named buffer,
1607 the named buffer contains both the old and new text,
1608 while the unnamed buffer contains only the new text.
1609 There is no way to explicitly reference the unnamed buffer.
1611 Historically, the contents of the unnamed buffer were discarded by many
1612 different commands, even ones that didn't store text into it.
1614 never discards the contents of the unnamed buffer until new text
1619 The characters <tab> and <space>.
1620 @cindex "<carriage-return>"
1621 @IP{<carriage-return>}
1623 The character represented by an ASCII
1625 This character is almost always treated identically to a
1626 @LI{<newline>}character, but differs in that it can be escaped into the file text or
1631 The character represented by an ASCII
1633 This character is almost always treated identically to a
1634 @LI{<control-M>}character, but differs in that it cannot be escaped into the file text or
1637 @comment .oh 'Vi/Ex Reference (Vi Commands)''USD:13-%'
1638 @comment .eh 'USD:13-%''Vi/Ex Reference (Vi Commands)'
1639 @node Vi Commands,(dir),(dir),(dir)
1640 @include vi.cmd.texi
1641 @comment .oh 'Vi/Ex Reference''USD:13-%'
1642 @comment .eh 'USD:13-%''Vi/Ex Reference'
1643 @chapter Ex Addressing
1649 commands are executed from
1651 relates to the current line.
1652 In general, the current line is the last line affected by a command.
1653 The exact effect on the current line is discussed under the description
1655 When the file contains no lines, the current line is zero.
1657 Addresses are constructed by one or more of the following methods:
1662 refers to the current line.
1666 refers to the last line of the file.
1671 @LI{N}is a positive number, refers to the N-th line of the file.
1677 refers to the line marked with the name
1683 commands for more information on how to mark lines.)
1685 A regular expression (RE) enclosed by slashes
1688 and it refers to the first line found by searching forward from the line
1690 the current line toward the end of the file, and stopping at the
1691 first line containing a string matching the RE.
1692 (The trailing slash can be omitted at the end of the command line.)
1694 If no RE is specified, i.e.@: the pattern is
1696 the last RE used in any command is used in the search.
1700 option is set, the RE is handled as an extended RE, not a basic RE.
1703 option is set, the search wraps around to the beginning of the file
1704 and continues up to and including the current line, so that the entire
1709 is accepted for historic reasons,
1713 An RE enclosed in question marks
1715 addresses the first line found by searching backward from the line
1717 the current line, toward the beginning of the file and stopping at the
1718 first line containing a string matching the RE.
1719 (The trailing question mark can be omitted at the end of a command line.)
1721 If no RE is specified, i.e.@: the pattern is
1723 the last RE used in any command is used in the search.
1727 option is set, the RE is handled as an extended RE, not a basic RE.
1730 option is set, the search wraps around from the beginning of the file to
1731 the end of the file and continues up to and including the current line,
1732 so that the entire file is searched.
1736 is accepted for historic reasons, and is identical to
1739 An address followed by a plus sign
1743 followed by a number is an offset address and refers to the address
1744 plus (or minus) the indicated number of lines.
1745 If the address is omitted, the addition or subtraction is done with
1746 respect to the current line.
1752 followed by a number is an offset from the current line.
1758 An address ending with
1762 has 1 added to or subtracted from the address, respectively.
1763 As a consequence of this rule and of the previous rule, the address
1765 refers to the line preceding the current line.
1770 characters have a cumulative effect.
1773 refers to the current line plus 3.
1777 is equivalent to the address range
1782 commands require zero, one, or two addresses.
1783 It is an error to specify an address to a command which requires zero
1786 If the user provides more than the expected number of addresses to any
1788 command, the first addresses specified are discarded.
1791 prints lines 3 through 5, because the
1793 command only takes two addresses.
1795 The addresses in a range are separated from each other by a comma
1799 In the latter case, the current line
1801 is set to the first address, and only then is the second address calculated.
1802 This feature can be used to determine the starting line for forward and
1803 backward searches (see rules (5) and (6) above).
1804 The second address of any two-address sequence corresponds to a line that
1805 follows, in the file, the line corresponding to the first address.
1806 The first address must be less than or equal to the second address.
1807 The first address must be greater than or equal to the first line of the
1808 file, and the last address must be less than or equal to the last line
1810 @comment .oh 'Vi/Ex Reference (Ex Commands)''USD:13-%'
1811 @comment .eh 'USD:13-%''Vi/Ex Reference (Ex Commands)'
1812 @node Ex Commands,(dir),(dir),(dir)
1813 @include ex.cmd.texi
1814 @comment .oh 'Vi/Ex Reference (Options)''USD:13-%'
1815 @comment .eh 'USD:13-%''Vi/Ex Reference (Options)'
1816 @include set.opt.texi
1817 @comment .oh 'Vi/Ex Reference''USD:13-%'
1818 @comment .eh 'USD:13-%''Vi/Ex Reference'
1822 @comment Force the TOC to an odd page, in case it's a duplex printer.