xref: /minix3/external/bsd/nvi/dist/docs/vi.ref/vi.texi (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc\input texinfo
2*84d9c625SLionel Sambuc@setfilename vi.ref.info
3*84d9c625SLionel Sambuc
4*84d9c625SLionel Sambuc@setchapternewpage off
5*84d9c625SLionel Sambuc@syncodeindex fn cp
6*84d9c625SLionel Sambuc
7*84d9c625SLionel Sambuc@comment  Copyright (c) 1994
8*84d9c625SLionel Sambuc@comment      The Regents of the University of California.  All rights reserved.
9*84d9c625SLionel Sambuc@comment  Copyright (c) 1994, 1995, 1996
10*84d9c625SLionel Sambuc@comment 	Keith Bostic.  All rights reserved.
11*84d9c625SLionel Sambuc@comment
12*84d9c625SLionel Sambuc@comment  This document may not be republished without written permission from
13*84d9c625SLionel Sambuc@comment  Keith Bostic.
14*84d9c625SLionel Sambuc@comment
15*84d9c625SLionel Sambuc@comment  See the LICENSE file for redistribution information.
16*84d9c625SLionel Sambuc@comment
17*84d9c625SLionel Sambuc@comment      Id: vi.texi,v 8.1 2001/08/18 20:43:50 skimo Exp  (Berkeley) Date: 2001/08/18 20:43:50
18*84d9c625SLionel Sambuc@comment
19*84d9c625SLionel Sambuc@comment
20*84d9c625SLionel Sambuc
21*84d9c625SLionel Sambuc@dircategory Editors
22*84d9c625SLionel Sambuc@direntry
23*84d9c625SLionel Sambuc* vi: (vi.info).                The vi editor.
24*84d9c625SLionel Sambuc@end direntry
25*84d9c625SLionel Sambuc
26*84d9c625SLionel Sambuc@node Top,(dir),(dir),(dir)
27*84d9c625SLionel Sambuc@menu
28*84d9c625SLionel Sambuc* Vi Commands::
29*84d9c625SLionel Sambuc* Ex Commands::
30*84d9c625SLionel Sambuc@end menu
31*84d9c625SLionel Sambuc@include ref.texi
32*84d9c625SLionel Sambuc@titlepage
33*84d9c625SLionel Sambuc@center @titlefont{Vi/Ex Reference Manual}
34*84d9c625SLionel Sambuc@sp 1
35*84d9c625SLionel Sambuc@center @emph{Keith Bostic}
36*84d9c625SLionel Sambuc@sp 1
37*84d9c625SLionel Sambuc@center Computer Science Division
38*84d9c625SLionel Sambuc@center Department of Electrical Engineering and Computer Science
39*84d9c625SLionel Sambuc@center University of California, Berkeley
40*84d9c625SLionel Sambuc@center Berkeley, California  94720
41*84d9c625SLionel Sambuc@sp 1
42*84d9c625SLionel Sambuc@center @emph{Sven Verdoolaege}
43*84d9c625SLionel Sambuc@sp 1
44*84d9c625SLionel Sambuc@center @today
45*84d9c625SLionel Sambuc@sp 3
46*84d9c625SLionel Sambuc@center @emph{Abstract}
47*84d9c625SLionel Sambuc
48*84d9c625SLionel SambucThis document is the reference guide for the 4.4BSD
49*84d9c625SLionel Sambucimplementations of
50*84d9c625SLionel Sambuc@EV{nex,nvi},
51*84d9c625SLionel Sambucwhich are implementations of the historic Berkeley
52*84d9c625SLionel Sambuc@EV{ex,vi}
53*84d9c625SLionel Sambuceditors.
54*84d9c625SLionel Sambuc@vskip 0pt plus 1filll
55*84d9c625SLionel SambucCopyright @copyright{} 1991, 1992, 1993, 1994@*
56*84d9c625SLionel Sambuc@hskip 2cm The Regents of the University of California.  All Rights Reserved.@*
57*84d9c625SLionel SambucCopyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996@*
58*84d9c625SLionel Sambuc@hskip 2cm Keith Bostic.  All Rights Reserved.@*
59*84d9c625SLionel SambucCopyright @copyright{} 2001@*
60*84d9c625SLionel Sambuc@hskip 2cm Sven Verdoolaege.  All Rights Reserved.@*
61*84d9c625SLionel Sambuc@page
62*84d9c625SLionel Sambuc@center@emph{Acknowledgements}
63*84d9c625SLionel Sambuc@sp 1
64*84d9c625SLionel Sambuc
65*84d9c625SLionel SambucBruce Englar encouraged the early development of the historic
66*84d9c625SLionel Sambuc@EV{ex,vi}
67*84d9c625SLionel Sambuceditor.
68*84d9c625SLionel SambucPeter Kessler helped bring sanity to version 2's command layout.
69*84d9c625SLionel SambucBill Joy wrote versions 1 and 2.0 through 2.7,
70*84d9c625SLionel Sambucand created the framework that users see in the present editor.
71*84d9c625SLionel SambucMark Horton added macros and other features and made
72*84d9c625SLionel Sambuc@EV{ex,vi}
73*84d9c625SLionel Sambucwork on a large number of terminals and Unix systems.
74*84d9c625SLionel Sambuc
75*84d9c625SLionel Sambuc@CO{Nvi}
76*84d9c625SLionel Sambuc is originally derived from software contributed to the University of
77*84d9c625SLionel SambucCalifornia, Berkeley by Steve Kirkendall, the author of the
78*84d9c625SLionel Sambuc@CO{vi}
79*84d9c625SLionel Sambuc clone
80*84d9c625SLionel Sambuc@CO{elvis}.
81*84d9c625SLionel Sambuc
82*84d9c625SLionel SambucIEEE Standard Portable Operating System Interface for Computer
83*84d9c625SLionel SambucEnvironments (POSIX) 1003.2 style Regular Expression support was
84*84d9c625SLionel Sambucdone by Henry Spencer.
85*84d9c625SLionel Sambuc
86*84d9c625SLionel SambucThe curses library was originally done by Ken Arnold.
87*84d9c625SLionel SambucScrolling and reworking for
88*84d9c625SLionel Sambuc@CO{nvi}
89*84d9c625SLionel Sambuc was done by Elan Amir.
90*84d9c625SLionel Sambuc
91*84d9c625SLionel SambucGeorge Neville-Neil added the Tcl interpreter,
92*84d9c625SLionel Sambucand Sven Verdoolaege added the Perl interpreter.
93*84d9c625SLionel Sambuc
94*84d9c625SLionel SambucRob Mayoff added Cscope support.
95*84d9c625SLionel Sambuc
96*84d9c625SLionel SambucThe Institute of Electrical and Electronics Engineers has
97*84d9c625SLionel Sambucgiven us permission to reprint portions of their documentation.
98*84d9c625SLionel SambucPortions of this document are reprinted and reproduced from
99*84d9c625SLionel SambucIEEE Std 1003.2-1992, IEEE Standard Portable Operating
100*84d9c625SLionel SambucSystem Interface for Computer Environments (POSIX),
101*84d9c625SLionel Sambuccopyright 1992 by the Institute of Electrical and Electronics
102*84d9c625SLionel SambucEngineers, Inc.
103*84d9c625SLionel Sambuc
104*84d9c625SLionel SambucThe financial support of UUNET Communications Services is gratefully
105*84d9c625SLionel Sambucacknowledged.
106*84d9c625SLionel Sambuc@end titlepage
107*84d9c625SLionel Sambuc@contents
108*84d9c625SLionel Sambuc@chapter Description
109*84d9c625SLionel Sambuc
110*84d9c625SLionel Sambuc@CO{Vi}
111*84d9c625SLionel Sambuc is a screen oriented text editor.
112*84d9c625SLionel Sambuc@CO{Ex}
113*84d9c625SLionel Sambuc is a line-oriented text editor.
114*84d9c625SLionel Sambuc@CO{Ex}
115*84d9c625SLionel Sambuc and
116*84d9c625SLionel Sambuc@CO{vi}
117*84d9c625SLionel Sambuc are different interfaces to the same program,
118*84d9c625SLionel Sambucand it is possible to switch back and forth during an edit session.
119*84d9c625SLionel Sambuc@CO{View}
120*84d9c625SLionel Sambuc is the equivalent of using the
121*84d9c625SLionel Sambuc@strong{-R}
122*84d9c625SLionel Sambuc(read-only) option of
123*84d9c625SLionel Sambuc@CO{vi}  .
124*84d9c625SLionel Sambuc
125*84d9c625SLionel SambucThis reference manual is the one provided with the
126*84d9c625SLionel Sambuc@EV{nex,nvi}
127*84d9c625SLionel Sambucversions of the
128*84d9c625SLionel Sambuc@EV{ex,vi}
129*84d9c625SLionel Sambuctext editors.
130*84d9c625SLionel Sambuc@EV{Nex,nvi}
131*84d9c625SLionel Sambucare intended as bug-for-bug compatible replacements for the original
132*84d9c625SLionel SambucFourth Berkeley Software Distribution (4BSD)
133*84d9c625SLionel Sambuc@EV{ex,vi}
134*84d9c625SLionel Sambucprograms.
135*84d9c625SLionel SambucThis reference manual is accompanied by a traditional-style manual page.
136*84d9c625SLionel SambucThat manual page describes the functionality found in
137*84d9c625SLionel Sambuc@EV{ex,vi}
138*84d9c625SLionel Sambucin far less detail than the description here.
139*84d9c625SLionel SambucIn addition, it describes the system interface to
140*84d9c625SLionel Sambuc@EV{ex,vi},
141*84d9c625SLionel Sambuce.g. command line options, session recovery, signals,
142*84d9c625SLionel Sambucenvironmental variables, and similar things.
143*84d9c625SLionel Sambuc
144*84d9c625SLionel SambucThis reference is intended for users already familiar with
145*84d9c625SLionel Sambuc@EV{ex,vi}.
146*84d9c625SLionel SambucAnyone else should almost certainly read a good tutorial on the
147*84d9c625SLionel Sambuceditor first.
148*84d9c625SLionel SambucIf you are in an unfamiliar environment,
149*84d9c625SLionel Sambucand you absolutely have to get work done immediately,
150*84d9c625SLionel Sambucsee the section entitled
151*84d9c625SLionel Sambuc@QB{Fast Startup}
152*84d9c625SLionel Sambucin the manual page.
153*84d9c625SLionel SambucIt is probably enough to get you started.
154*84d9c625SLionel Sambuc
155*84d9c625SLionel SambucThere are a few features in
156*84d9c625SLionel Sambuc@EV{nex,nvi}
157*84d9c625SLionel Sambucthat are not found in historic versions of
158*84d9c625SLionel Sambuc@EV{ex,vi}.
159*84d9c625SLionel SambucSome of the more interesting of those features are briefly described
160*84d9c625SLionel Sambucin the next section, entitled
161*84d9c625SLionel Sambuc@QB{Additional Features} .
162*84d9c625SLionel SambucFor the rest of this document,
163*84d9c625SLionel Sambuc@EV{nex,nvi}
164*84d9c625SLionel Sambucis used only when it is necessary to distinguish it from the historic
165*84d9c625SLionel Sambucimplementations of
166*84d9c625SLionel Sambuc@EV{ex,vi}.
167*84d9c625SLionel Sambuc
168*84d9c625SLionel SambucFuture versions of this software will be periodically made available
169*84d9c625SLionel Sambucby anonymous ftp, and can be retrieved from
170*84d9c625SLionel Sambuc@LI{ftp.cs.berkeley.edu},
171*84d9c625SLionel Sambucin the directory
172*84d9c625SLionel Sambuc@LI{ucb/4bsd}.
173*84d9c625SLionel Sambuc@chapter Additional Features in Nex/Nvi
174*84d9c625SLionel Sambuc
175*84d9c625SLionel SambucThere are a few features in
176*84d9c625SLionel Sambuc@EV{nex,nvi}
177*84d9c625SLionel Sambucthat are not found in historic versions of
178*84d9c625SLionel Sambuc@EV{ex,vi}.
179*84d9c625SLionel SambucSome of the more interesting of these are as follows:
180*84d9c625SLionel Sambuc@itemize @bullet
181*84d9c625SLionel Sambuc@IP{8-bit clean data, large lines, files}
182*84d9c625SLionel Sambuc
183*84d9c625SLionel Sambuc@EV{Nex,nvi}
184*84d9c625SLionel Sambucwill edit any format file.
185*84d9c625SLionel SambucLine lengths are limited by available memory,
186*84d9c625SLionel Sambucand file sizes are limited by available disk space.
187*84d9c625SLionel SambucThe
188*84d9c625SLionel Sambuc@CO{vi}
189*84d9c625SLionel Sambuc text input mode command
190*84d9c625SLionel Sambuc@CO{<control-X>}
191*84d9c625SLionel Sambuc can insert any possible character value into the text.
192*84d9c625SLionel Sambuc@IP{Background and foreground screens}
193*84d9c625SLionel Sambuc
194*84d9c625SLionel SambucThe
195*84d9c625SLionel Sambuc@CO{bg}
196*84d9c625SLionel Sambuc command backgrounds the current screen, and the
197*84d9c625SLionel Sambuc@CO{fg}
198*84d9c625SLionel Sambuc command foregrounds backgrounded screens.
199*84d9c625SLionel SambucThe
200*84d9c625SLionel Sambuc@CO{display}
201*84d9c625SLionel Sambuc command can be used to list the background screens.
202*84d9c625SLionel Sambuc@IP{Command Editing}
203*84d9c625SLionel Sambuc
204*84d9c625SLionel SambucYou can enter a normal editing window on the collected commands that
205*84d9c625SLionel Sambucyou've entered on the
206*84d9c625SLionel Sambuc@CO{vi}
207*84d9c625SLionel Sambuc colon command-line,
208*84d9c625SLionel Sambucand then modify and/or execute the commands.
209*84d9c625SLionel SambucSee the
210*84d9c625SLionel Sambuc@OP{cedit}
211*84d9c625SLionel Sambucedit option for more information.
212*84d9c625SLionel Sambuc@IP{Displays}
213*84d9c625SLionel Sambuc
214*84d9c625SLionel SambucThe
215*84d9c625SLionel Sambuc@CO{display}
216*84d9c625SLionel Sambuc command can be used to display the current buffers, the backgrounded
217*84d9c625SLionel Sambucscreens, and the tags stack.
218*84d9c625SLionel Sambuc@IP{Extended Regular Expressions}
219*84d9c625SLionel Sambuc
220*84d9c625SLionel SambucThe
221*84d9c625SLionel Sambuc@CO{extended}
222*84d9c625SLionel Sambuc option causes Regular Expressions to be interpreted as as Extended
223*84d9c625SLionel SambucRegular Expressions, (i.e.@: @command{egrep}(1) style Regular Expressions).
224*84d9c625SLionel Sambuc@IP{File Name Completion}
225*84d9c625SLionel Sambuc
226*84d9c625SLionel SambucIt is possible to do file name completion and file name displays when
227*84d9c625SLionel Sambucentering commands on the
228*84d9c625SLionel Sambuc@CO{vi}
229*84d9c625SLionel Sambuc colon command-line.
230*84d9c625SLionel SambucSee the
231*84d9c625SLionel Sambuc@OP{filec}
232*84d9c625SLionel Sambucoption for more information.
233*84d9c625SLionel Sambuc@IP{Infinite undo}
234*84d9c625SLionel Sambuc
235*84d9c625SLionel SambucChanges made during an edit session may be rolled backward and forward.
236*84d9c625SLionel SambucA
237*84d9c625SLionel Sambuc@CO{.}
238*84d9c625SLionel Sambuc command immediately after a
239*84d9c625SLionel Sambuc@CO{u}
240*84d9c625SLionel Sambuc command continues either forward or backward depending on whether the
241*84d9c625SLionel Sambuc@CO{u}
242*84d9c625SLionel Sambuc command was an undo or a redo.
243*84d9c625SLionel Sambuc@IP{Left-right scrolling}
244*84d9c625SLionel Sambuc
245*84d9c625SLionel SambucThe
246*84d9c625SLionel Sambuc@CO{leftright}
247*84d9c625SLionel Sambuc option causes
248*84d9c625SLionel Sambuc@CO{nvi}
249*84d9c625SLionel Sambuc to do left-right screen scrolling, instead of the traditional
250*84d9c625SLionel Sambuc@CO{vi}
251*84d9c625SLionel Sambuc line wrapping.
252*84d9c625SLionel Sambuc@IP{Message Catalogs}
253*84d9c625SLionel Sambuc
254*84d9c625SLionel SambucIt is possible to display informational and error messages in different
255*84d9c625SLionel Sambuclanguages by providing a catalog of messages.
256*84d9c625SLionel SambucSee the
257*84d9c625SLionel Sambuc@OP{msgcat}
258*84d9c625SLionel Sambucoption and the file
259*84d9c625SLionel Sambuc@LI{catalog/README}for more information.
260*84d9c625SLionel Sambuc@IP{Incrementing numbers}
261*84d9c625SLionel Sambuc
262*84d9c625SLionel SambucThe
263*84d9c625SLionel Sambuc@CO{#}
264*84d9c625SLionel Sambuc command increments or decrements the number referenced by the cursor.
265*84d9c625SLionel Sambuc@IP{Previous file}
266*84d9c625SLionel Sambuc
267*84d9c625SLionel SambucThe
268*84d9c625SLionel Sambuc@CO{previous}
269*84d9c625SLionel Sambuc command edits the previous file from the argument list.
270*84d9c625SLionel Sambuc@IP{Scripting languages}
271*84d9c625SLionel Sambuc
272*84d9c625SLionel SambucThe
273*84d9c625SLionel Sambuc@CO{:pe[rl] cmd},
274*84d9c625SLionel Sambuc@CO{:perld[o] cmd}
275*84d9c625SLionel Sambucand
276*84d9c625SLionel Sambuc@CO{:tc[l] cmd}
277*84d9c625SLionel Sambuccommands execute Perl and Tcl/Tk commands, respectively,
278*84d9c625SLionel Sambucon lines from the edit buffer.
279*84d9c625SLionel SambucSee the
280*84d9c625SLionel Sambuc@QB{Scripting Languages}
281*84d9c625SLionel Sambucsection and the specific commands for more information.
282*84d9c625SLionel Sambuc@comment @IP{Shell screens}
283*84d9c625SLionel Sambuc
284*84d9c625SLionel Sambuc@comment The
285*84d9c625SLionel Sambuc@comment @CO{:sc[ript] [file ...]}
286*84d9c625SLionel Sambuc@comment command runs a shell in the screen.
287*84d9c625SLionel Sambuc@comment Editing is unchanged, with the exception that a \fC<carriage-return>\fP
288*84d9c625SLionel Sambuc@comment enters the current line (stripped of any prompt) as input to the
289*84d9c625SLionel Sambuc@comment shell.
290*84d9c625SLionel Sambuc@IP{Split screens}
291*84d9c625SLionel Sambuc
292*84d9c625SLionel SambucThe
293*84d9c625SLionel Sambuc@CO{Edit}  ,
294*84d9c625SLionel Sambuc@CO{Ex}  ,
295*84d9c625SLionel Sambuc@CO{Next}  ,
296*84d9c625SLionel Sambuc@CO{Previous}  ,
297*84d9c625SLionel Sambuc@CO{Tag}
298*84d9c625SLionel Sambuc and
299*84d9c625SLionel Sambuc@CO{Visual}
300*84d9c625SLionel Sambuc (in
301*84d9c625SLionel Sambuc@CO{vi}
302*84d9c625SLionel Sambuc mode) commands divide the screen into multiple editing regions and
303*84d9c625SLionel Sambucthen perform their normal function in a new screen area.
304*84d9c625SLionel SambucThe
305*84d9c625SLionel Sambuc@CO{<control-W>}
306*84d9c625SLionel Sambuc command rotates between the foreground screens.
307*84d9c625SLionel SambucThe
308*84d9c625SLionel Sambuc@CO{resize}
309*84d9c625SLionel Sambuc command can be used to grow or shrink a particular screen.
310*84d9c625SLionel Sambuc@IP{Tag stacks}
311*84d9c625SLionel Sambuc
312*84d9c625SLionel SambucTags are now maintained in a stack.
313*84d9c625SLionel SambucThe
314*84d9c625SLionel Sambuc@CO{<control-T>}
315*84d9c625SLionel Sambuc command returns to the previous tag location.
316*84d9c625SLionel SambucThe
317*84d9c625SLionel Sambuc@CO{tagpop}
318*84d9c625SLionel Sambuc command returns to the most recent tag location by default, or,
319*84d9c625SLionel Sambucoptionally to a specific tag number in the tag stack,
320*84d9c625SLionel Sambucor the most recent tag from a specified file.
321*84d9c625SLionel SambucThe
322*84d9c625SLionel Sambuc@CO{display}
323*84d9c625SLionel Sambuc command can be used to list the tags stack.
324*84d9c625SLionel SambucThe
325*84d9c625SLionel Sambuc@CO{tagtop}
326*84d9c625SLionel Sambuc command returns to the top of the tag stack.
327*84d9c625SLionel Sambuc@IP{Usage information}
328*84d9c625SLionel Sambuc
329*84d9c625SLionel SambucThe
330*84d9c625SLionel Sambuc@CO{exusage}
331*84d9c625SLionel Sambuc and
332*84d9c625SLionel Sambuc@CO{viusage}
333*84d9c625SLionel Sambuc commands provide usage information for all of the
334*84d9c625SLionel Sambuc@CO{ex}
335*84d9c625SLionel Sambuc and
336*84d9c625SLionel Sambuc@CO{vi}
337*84d9c625SLionel Sambuc commands by default, or, optionally, for a specific command or key.
338*84d9c625SLionel Sambuc@IP{Word search}
339*84d9c625SLionel Sambuc
340*84d9c625SLionel SambucThe
341*84d9c625SLionel Sambuc@CO{<control-A>}
342*84d9c625SLionel Sambuc command searches for the word referenced by the cursor.
343*84d9c625SLionel Sambuc@end itemize
344*84d9c625SLionel Sambuc@chapter Startup Information
345*84d9c625SLionel Sambuc
346*84d9c625SLionel Sambuc@EV{Ex,vi}
347*84d9c625SLionel Sambucinterprets one of two possible environmental variables and reads up to
348*84d9c625SLionel Sambucthree of five possible files during startup.
349*84d9c625SLionel SambucThe variables and files are expected to contain
350*84d9c625SLionel Sambuc@CO{ex}
351*84d9c625SLionel Sambuc commands, not
352*84d9c625SLionel Sambuc@CO{vi}
353*84d9c625SLionel Sambuc commands.
354*84d9c625SLionel SambucIn addition, they are interpreted
355*84d9c625SLionel Sambuc@emph{before}
356*84d9c625SLionel Sambucthe file to be edited is read, and therefore many
357*84d9c625SLionel Sambuc@CO{ex}
358*84d9c625SLionel Sambuc commands may not be used.
359*84d9c625SLionel SambucGenerally, any command that requires output to the screen or that
360*84d9c625SLionel Sambucneeds a file upon which to operate, will cause an error if included
361*84d9c625SLionel Sambucin a startup file or environmental variable.
362*84d9c625SLionel Sambuc
363*84d9c625SLionel SambucBecause the
364*84d9c625SLionel Sambuc@CO{ex}
365*84d9c625SLionel Sambuc command set supported by
366*84d9c625SLionel Sambuc@EV{nex,nvi}
367*84d9c625SLionel Sambucis a superset of the command set supported by historical implementations of
368*84d9c625SLionel Sambuc@CO{ex}  ,
369*84d9c625SLionel Sambuc@EV{nex,nvi}
370*84d9c625SLionel Sambuccan use the startup files created for the historical implementations,
371*84d9c625SLionel Sambucbut the converse may not be true.
372*84d9c625SLionel Sambuc
373*84d9c625SLionel SambucIf the
374*84d9c625SLionel Sambuc@strong{-s}
375*84d9c625SLionel Sambuc(the historic - option)
376*84d9c625SLionel Sambucis specified, or if standard input is redirected from a file,
377*84d9c625SLionel Sambucall environmental variables and startup files are ignored.
378*84d9c625SLionel Sambuc
379*84d9c625SLionel SambucOtherwise, startup files and environmental variables are handled
380*84d9c625SLionel Sambucin the following order:
381*84d9c625SLionel Sambuc@enumerate
382*84d9c625SLionel Sambuc@item
383*84d9c625SLionel SambucThe file
384*84d9c625SLionel Sambuc@LI{/etc/vi.exrc}is read,
385*84d9c625SLionel Sambucas long as it is owned by root or the effective user ID of the user.
386*84d9c625SLionel Sambuc@item
387*84d9c625SLionel SambucThe environmental variable
388*84d9c625SLionel Sambuc@LI{NEXINIT}(or the variable
389*84d9c625SLionel Sambuc@LI{EXINIT},
390*84d9c625SLionel Sambucif
391*84d9c625SLionel Sambuc@LI{NEXINIT}is not set) is interpreted.
392*84d9c625SLionel Sambuc@item
393*84d9c625SLionel SambucIf neither
394*84d9c625SLionel Sambuc@LI{NEXINIT}or
395*84d9c625SLionel Sambuc@LI{EXINIT}was set, and the
396*84d9c625SLionel Sambuc@LI{HOME}environmental variable is set, the file
397*84d9c625SLionel Sambuc@LI{$HOME/.nexrc}(or the file
398*84d9c625SLionel Sambuc@LI{$HOME/.exrc},
399*84d9c625SLionel Sambucif
400*84d9c625SLionel Sambuc@LI{$HOME/.nexrc}does not exist) is read,
401*84d9c625SLionel Sambucas long as the effective user ID of the user is root or is the same as
402*84d9c625SLionel Sambucthe owner of the file.
403*84d9c625SLionel Sambuc@sp 1
404*84d9c625SLionel SambucWhen the $HOME directory is being used for both
405*84d9c625SLionel Sambuc@EV{nex,nvi}
406*84d9c625SLionel Sambucand an historic implementation of
407*84d9c625SLionel Sambuc@EV{ex,vi},
408*84d9c625SLionel Sambuca possible solution is to put
409*84d9c625SLionel Sambuc@EV{nex,nvi}
410*84d9c625SLionel Sambucspecific commands in the
411*84d9c625SLionel Sambuc@LI{.nexrc}file, along with a
412*84d9c625SLionel Sambuc@CO{:source $HOME/.exrc}
413*84d9c625SLionel Sambuccommand to read in the commands common to both implementations.
414*84d9c625SLionel Sambuc@item
415*84d9c625SLionel SambucIf the
416*84d9c625SLionel Sambuc@OP{exrc}
417*84d9c625SLionel Sambucoption was turned on by one of the previous startup information
418*84d9c625SLionel Sambucsources, the file
419*84d9c625SLionel Sambuc@LI{.nexrc}(or the file
420*84d9c625SLionel Sambuc@LI{.exrc},
421*84d9c625SLionel Sambucif
422*84d9c625SLionel Sambuc@LI{.nexrc}does not exist) is read, as long as the effective user ID of the user
423*84d9c625SLionel Sambucis the same as the owner of the file.
424*84d9c625SLionel Sambuc@end enumerate
425*84d9c625SLionel Sambuc
426*84d9c625SLionel SambucNo startup file is read if it is writable by anyone other than its owner.
427*84d9c625SLionel Sambuc
428*84d9c625SLionel SambucIt is not an error for any of the startup environmental variables or files
429*84d9c625SLionel Sambucnot to exist.
430*84d9c625SLionel Sambuc
431*84d9c625SLionel SambucOnce all environmental variables are interpreted,
432*84d9c625SLionel Sambucand all startup files are read,
433*84d9c625SLionel Sambucthe first file to be edited is read in (or a temporary file is created).
434*84d9c625SLionel SambucThen, any commands specified using the
435*84d9c625SLionel Sambuc@strong{-c}
436*84d9c625SLionel Sambucoption are executed, in the context of that file.
437*84d9c625SLionel Sambuc@chapter Recovery
438*84d9c625SLionel Sambuc
439*84d9c625SLionel SambucThere is no recovery program for
440*84d9c625SLionel Sambuc@EV{nex,nvi},
441*84d9c625SLionel Sambucnor does
442*84d9c625SLionel Sambuc@EV{nex,nvi}
443*84d9c625SLionel Sambucrun setuid.
444*84d9c625SLionel SambucRecovery files are created readable and writable by the owner only.
445*84d9c625SLionel SambucUsers may recover any file which they can read,
446*84d9c625SLionel Sambucand the superuser may recover any edit session.
447*84d9c625SLionel Sambuc
448*84d9c625SLionel SambucEdit sessions are backed by files in the directory named by the
449*84d9c625SLionel Sambuc@OP{recdir}
450*84d9c625SLionel Sambucoption (the directory
451*84d9c625SLionel Sambuc@LI{/var/tmp/vi.recover}by default), and are named
452*84d9c625SLionel Sambuc@QC{vi.XXXXXX},
453*84d9c625SLionel Sambucwhere
454*84d9c625SLionel Sambuc@QC{XXXXXX}
455*84d9c625SLionel Sambucis a number related to the process ID.
456*84d9c625SLionel SambucWhen a file is first modified,
457*84d9c625SLionel Sambuca second recovery file containing an email message for the user is created,
458*84d9c625SLionel Sambucand is named
459*84d9c625SLionel Sambuc@QC{recover.XXXXXX},
460*84d9c625SLionel Sambucwhere, again,
461*84d9c625SLionel Sambuc@QC{XXXXXX}
462*84d9c625SLionel Sambucis associated with the process ID.
463*84d9c625SLionel SambucBoth files are removed at the end of a normal edit session,
464*84d9c625SLionel Sambucbut will remain if the edit session is abnormally terminated
465*84d9c625SLionel Sambucor the user runs the
466*84d9c625SLionel Sambuc@CO{ex}
467*84d9c625SLionel Sambuc @CO{preserve}
468*84d9c625SLionel Sambuc command.
469*84d9c625SLionel Sambuc
470*84d9c625SLionel SambucThe
471*84d9c625SLionel Sambuc@OP{recdir}
472*84d9c625SLionel Sambucoption may be set in either the user's or system's startup information,
473*84d9c625SLionel Sambucchanging the recovery directory.
474*84d9c625SLionel Sambuc(Note, however, that if a memory based file system is used as the backup
475*84d9c625SLionel Sambucdirectory, each system reboot will delete all of the recovery files!
476*84d9c625SLionel SambucThe same caution applies to directories such as
477*84d9c625SLionel Sambuc@LI{/tmp}which are cleared of their contents by a system reboot, or
478*84d9c625SLionel Sambuc@LI{/usr/tmp}which is periodically cleared of old files on many systems.)
479*84d9c625SLionel Sambuc
480*84d9c625SLionel SambucThe recovery directory should be owned by root, or at least by a pseudo-user.
481*84d9c625SLionel SambucIn addition, if directory
482*84d9c625SLionel Sambuc@QQ{sticky-bit}
483*84d9c625SLionel Sambucsemantics are available, the directory should have the sticky-bit
484*84d9c625SLionel Sambucset so that files may only be removed by their owners.
485*84d9c625SLionel SambucThe recovery directory must be read, write, and executable by any user,
486*84d9c625SLionel Sambuci.e.@: mode 1777.
487*84d9c625SLionel Sambuc
488*84d9c625SLionel SambucIf the recovery directory does not exist,
489*84d9c625SLionel Sambuc@EV{ex,vi}
490*84d9c625SLionel Sambucwill attempt to create it.
491*84d9c625SLionel SambucThis can result in the recovery directory being owned by a normal user,
492*84d9c625SLionel Sambucwhich means that that user will be able to remove other user's recovery
493*84d9c625SLionel Sambucand backup files.
494*84d9c625SLionel SambucThis is annoying, but is not a security issue as the user cannot
495*84d9c625SLionel Sambucotherwise access or modify the files.
496*84d9c625SLionel Sambuc
497*84d9c625SLionel SambucThe recovery file has all of the necessary information in it to enable the
498*84d9c625SLionel Sambucuser to recover the edit session.
499*84d9c625SLionel SambucIn addition, it has all of the necessary email headers for
500*84d9c625SLionel Sambuc@XR{sendmail,8}.
501*84d9c625SLionel SambucWhen the system is rebooted, all of the files in
502*84d9c625SLionel Sambuc@LI{/var/tmp/vi.recover}named
503*84d9c625SLionel Sambuc@QC{recover.XXXXXX}
504*84d9c625SLionel Sambucshould be sent to their owners, by email, using the
505*84d9c625SLionel Sambuc@strong{-t}
506*84d9c625SLionel Sambucoption of
507*84d9c625SLionel Sambuc@CO{sendmail}
508*84d9c625SLionel Sambuc (or a similar mechanism in other mailers).
509*84d9c625SLionel SambucIf
510*84d9c625SLionel Sambuc@EV{ex,vi}
511*84d9c625SLionel Sambucreceives a hangup (SIGHUP) signal, or the user executes the
512*84d9c625SLionel Sambuc@CO{ex}
513*84d9c625SLionel Sambuc @CO{preserve}
514*84d9c625SLionel Sambuc command,
515*84d9c625SLionel Sambuc@EV{ex,vi}
516*84d9c625SLionel Sambucwill automatically email the recovery information to the user.
517*84d9c625SLionel Sambuc
518*84d9c625SLionel SambucIf your system does not have the
519*84d9c625SLionel Sambuc@CO{sendmail}
520*84d9c625SLionel Sambuc utility (or a mailer program which supports its interface)
521*84d9c625SLionel Sambucthe source file
522*84d9c625SLionel Sambuc@LI{nvi/common/recover.c}will have to be modified to use your local mail delivery programs.
523*84d9c625SLionel SambucNote, if
524*84d9c625SLionel Sambuc@EV{nex,nvi}
525*84d9c625SLionel Sambucis changed to use another mailer,
526*84d9c625SLionel Sambucit is important to remember that the owner of the file given to
527*84d9c625SLionel Sambucthe mailer is the
528*84d9c625SLionel Sambuc@EV{nex,nvi}
529*84d9c625SLionel Sambucuser, so nothing in the file should be trusted as it may have been
530*84d9c625SLionel Sambucmodified in an effort to compromise the system.
531*84d9c625SLionel Sambuc
532*84d9c625SLionel SambucFinally, the owner execute bit is set on backup files when they are
533*84d9c625SLionel Sambuccreated, and unset when they are first modified, e.g. backup files
534*84d9c625SLionel Sambucthat have no associated email recovery file will have this bit set.
535*84d9c625SLionel Sambuc(There is also a small window where empty files can be created and
536*84d9c625SLionel Sambucnot yet have this bit set.
537*84d9c625SLionel SambucThis is due to the method in which the files are created.)
538*84d9c625SLionel SambucSuch files should be deleted when the system reboots.
539*84d9c625SLionel Sambuc
540*84d9c625SLionel SambucA simple way to do this cleanup is to run the Bourne shell script
541*84d9c625SLionel Sambuc@CO{recover}  ,
542*84d9c625SLionel Sambucfrom your
543*84d9c625SLionel Sambuc@LI{/etc/rc.local}(or other system startup) file.
544*84d9c625SLionel SambucThe script should work with the historic Bourne shell,
545*84d9c625SLionel Sambuca POSIX 1003.2 shell or the Korn shell.
546*84d9c625SLionel SambucThe
547*84d9c625SLionel Sambuc@CO{recover}
548*84d9c625SLionel Sambuc script is installed as part of the
549*84d9c625SLionel Sambuc@EV{nex,nvi}
550*84d9c625SLionel Sambucinstallation process.
551*84d9c625SLionel Sambuc
552*84d9c625SLionel SambucConsult the manual page for details on recovering preserved or
553*84d9c625SLionel Sambucaborted editing sessions.
554*84d9c625SLionel Sambuc@chapter Sizing the Screen
555*84d9c625SLionel Sambuc
556*84d9c625SLionel SambucThe size of the screen can be set in a number of ways.
557*84d9c625SLionel Sambuc@EV{Ex,vi}
558*84d9c625SLionel Sambuctakes the following steps until values are obtained for both the
559*84d9c625SLionel Sambucnumber of rows and number of columns in the screen.
560*84d9c625SLionel Sambuc@enumerate
561*84d9c625SLionel Sambuc@item
562*84d9c625SLionel SambucIf the environmental variable
563*84d9c625SLionel Sambuc@LI{LINES}exists,
564*84d9c625SLionel Sambucit is used to specify the number of rows in the screen.
565*84d9c625SLionel Sambuc@item
566*84d9c625SLionel SambucIf the environmental variable
567*84d9c625SLionel Sambuc@LI{COLUMNS}exists,
568*84d9c625SLionel Sambucit is used to specify the number of columns in the screen.
569*84d9c625SLionel Sambuc@item
570*84d9c625SLionel SambucThe TIOCGWINSZ
571*84d9c625SLionel Sambuc@XR{ioctl,2}
572*84d9c625SLionel Sambucis attempted on the standard error file descriptor.
573*84d9c625SLionel Sambuc@item
574*84d9c625SLionel SambucThe termcap entry (or terminfo entry on System V machines)
575*84d9c625SLionel Sambucis checked for the
576*84d9c625SLionel Sambuc@QQ{li}
577*84d9c625SLionel Sambucentry (rows) and the
578*84d9c625SLionel Sambuc@QQ{co}
579*84d9c625SLionel Sambucentry (columns).
580*84d9c625SLionel Sambuc@item
581*84d9c625SLionel SambucThe number of rows is set to 24, and the number of columns is set to 80.
582*84d9c625SLionel Sambuc@end enumerate
583*84d9c625SLionel Sambuc
584*84d9c625SLionel SambucIf a window change size signal (SIGWINCH) is received,
585*84d9c625SLionel Sambucthe new window size is retrieved using the TIOCGWINSZ
586*84d9c625SLionel Sambuc@XR{ioctl,2}
587*84d9c625SLionel Sambuccall, and all other information is ignored.
588*84d9c625SLionel Sambuc@chapter Character Display
589*84d9c625SLionel Sambuc
590*84d9c625SLionel SambucIn both
591*84d9c625SLionel Sambuc@CO{ex}
592*84d9c625SLionel Sambuc and
593*84d9c625SLionel Sambuc@CO{vi}
594*84d9c625SLionel Sambuc printable characters as defined by
595*84d9c625SLionel Sambuc@XR{isprint,3}
596*84d9c625SLionel Sambucare displayed using the local character set.
597*84d9c625SLionel Sambuc
598*84d9c625SLionel SambucNon-printable characters, for which
599*84d9c625SLionel Sambuc@XR{iscntrl,3}
600*84d9c625SLionel Sambucreturns true, and which are less than octal \e040,
601*84d9c625SLionel Sambucare displayed as the string
602*84d9c625SLionel Sambuc@QT{^<character>},
603*84d9c625SLionel Sambucwhere
604*84d9c625SLionel Sambuc@LI{<character>}is the character that is the original character's value offset from the
605*84d9c625SLionel Sambuc@QT{@@}
606*84d9c625SLionel Sambuccharacter.
607*84d9c625SLionel SambucFor example, the octal character \e001 is displayed as
608*84d9c625SLionel Sambuc@QT{^A}.
609*84d9c625SLionel SambucIf
610*84d9c625SLionel Sambuc@XR{iscntrl,3}
611*84d9c625SLionel Sambucreturns true for the octal character \e177,
612*84d9c625SLionel Sambucit is displayed as the string
613*84d9c625SLionel Sambuc@QT{^?}.
614*84d9c625SLionel SambucAll other characters are displayed as either hexadecimal values,
615*84d9c625SLionel Sambucin the form
616*84d9c625SLionel Sambuc@QT{0x<high-halfbyte> ... 0x<low-halfbyte>},
617*84d9c625SLionel Sambucor as octal values, in the form
618*84d9c625SLionel Sambuc@QT{\e<high-one-or-two-bits> ... \e<low-three-bits>}.
619*84d9c625SLionel SambucThe display of unknown characters is based on the value of the
620*84d9c625SLionel Sambuc@OP{octal}
621*84d9c625SLionel Sambucoption.
622*84d9c625SLionel Sambuc
623*84d9c625SLionel SambucIn
624*84d9c625SLionel Sambuc@CO{vi}
625*84d9c625SLionel Sambuc command mode, the cursor is always positioned on the last column of
626*84d9c625SLionel Sambuccharacters which take up more than one column on the screen.
627*84d9c625SLionel SambucIn
628*84d9c625SLionel Sambuc@CO{vi}
629*84d9c625SLionel Sambuc text input mode, the cursor is positioned on the first column of
630*84d9c625SLionel Sambuccharacters which take up more than one column on the screen.
631*84d9c625SLionel Sambuc@chapter Multiple Screens
632*84d9c625SLionel Sambuc
633*84d9c625SLionel Sambuc@CO{Nvi}
634*84d9c625SLionel Sambuc supports multiple screens by dividing the window into regions.
635*84d9c625SLionel SambucIt also supports stacks of screens by permitting the user to change
636*84d9c625SLionel Sambucthe set of screens that are currently displayed.
637*84d9c625SLionel Sambuc
638*84d9c625SLionel SambucThe
639*84d9c625SLionel Sambuc@CO{Edit}  ,
640*84d9c625SLionel Sambuc@CO{Ex}  ,
641*84d9c625SLionel Sambuc@CO{Fg}  ,
642*84d9c625SLionel Sambuc@CO{Next}  ,
643*84d9c625SLionel Sambuc@CO{Previous}  ,
644*84d9c625SLionel Sambuc@CO{Tag}
645*84d9c625SLionel Sambuc and
646*84d9c625SLionel Sambuc@CO{Visual}
647*84d9c625SLionel Sambuc (in
648*84d9c625SLionel Sambuc@CO{vi}
649*84d9c625SLionel Sambuc mode)
650*84d9c625SLionel Sambuccommands divide the current screen into two regions of approximately
651*84d9c625SLionel Sambucequal size and then perform their usual action in a new screen area.
652*84d9c625SLionel SambucIf the cursor is in the lower half of the screen, the screen will split
653*84d9c625SLionel Sambucup, i.e.@: the new screen will be above the old one.
654*84d9c625SLionel SambucIf the cursor is in the upper half of the screen, the new screen will be
655*84d9c625SLionel Sambucbelow the old one.
656*84d9c625SLionel Sambuc
657*84d9c625SLionel SambucWhen more than one screen is editing a file, changes in any screen are
658*84d9c625SLionel Sambucreflected in all other screens editing the same file.
659*84d9c625SLionel SambucExiting a screen without saving any changes (or explicitly discarding
660*84d9c625SLionel Sambucthem) is permitted until the last screen editing the file is exited,
661*84d9c625SLionel Sambucat which time the changes must be saved or discarded.
662*84d9c625SLionel Sambuc
663*84d9c625SLionel SambucThe
664*84d9c625SLionel Sambuc@CO{resize}
665*84d9c625SLionel Sambuc command permits resizing of individual screens.
666*84d9c625SLionel SambucScreens may be grown, shrunk or set to an absolute number of rows.
667*84d9c625SLionel Sambuc
668*84d9c625SLionel SambucThe
669*84d9c625SLionel Sambuc@CO{^W}
670*84d9c625SLionel Sambuc command is used to switch between screens.
671*84d9c625SLionel SambucEach
672*84d9c625SLionel Sambuc@CO{^W}
673*84d9c625SLionel Sambuc moves to the next lower screen in the window, or to the first screen
674*84d9c625SLionel Sambucin the window if there are no lower screens.
675*84d9c625SLionel Sambuc
676*84d9c625SLionel SambucThe
677*84d9c625SLionel Sambuc@CO{bg}
678*84d9c625SLionel Sambuc command
679*84d9c625SLionel Sambuc@QQ{backgrounds}
680*84d9c625SLionel Sambucthe current screen.
681*84d9c625SLionel SambucThe screen disappears from the window,
682*84d9c625SLionel Sambucand the rows it occupied are taken over by a neighboring screen.
683*84d9c625SLionel SambucIt is an error to attempt to background the only screen in the window.
684*84d9c625SLionel Sambuc
685*84d9c625SLionel SambucThe
686*84d9c625SLionel Sambuc@CO{display screens}
687*84d9c625SLionel Sambuccommand displays the names of the files associated with the current
688*84d9c625SLionel Sambucbackgrounded screens in the window.
689*84d9c625SLionel Sambuc
690*84d9c625SLionel SambucThe
691*84d9c625SLionel Sambuc@CO{fg [file]}
692*84d9c625SLionel Sambuccommand moves the specified screen from the list of backgrounded screens
693*84d9c625SLionel Sambucto the foreground.
694*84d9c625SLionel SambucIf no file argument is specified, the first screen on the list is
695*84d9c625SLionel Sambucforegrounded.
696*84d9c625SLionel SambucBy default,
697*84d9c625SLionel Sambucforegrounding consists of backgrounding the current screen,
698*84d9c625SLionel Sambucand replacing its space in the window with the foregrounded screen.
699*84d9c625SLionel Sambuc
700*84d9c625SLionel SambucCapitalizing the first letter of the command, i.e.@:
701*84d9c625SLionel Sambuc@CO{Fg}  ,
702*84d9c625SLionel Sambucwill foreground the backgrounded screen in a new screen instead of
703*84d9c625SLionel Sambucswapping it with the current screen.
704*84d9c625SLionel Sambuc
705*84d9c625SLionel SambucIf the last foregrounded screen in the window is exited,
706*84d9c625SLionel Sambucand there are backgrounded screens,
707*84d9c625SLionel Sambucthe first screen on the list of backgrounded screens takes over the window.
708*84d9c625SLionel Sambuc@chapter Tags, Tag Stacks, and Cscope
709*84d9c625SLionel Sambuc
710*84d9c625SLionel Sambuc@CO{Nvi}
711*84d9c625SLionel Sambuc supports the historic
712*84d9c625SLionel Sambuc@CO{vi}
713*84d9c625SLionel Sambuc tag command
714*84d9c625SLionel Sambuc@CO{<control-]>}  ,
715*84d9c625SLionel Sambucand the historic
716*84d9c625SLionel Sambuc@CO{ex}
717*84d9c625SLionel Sambuc tag command
718*84d9c625SLionel Sambuc@CO{tag}  .
719*84d9c625SLionel SambucThese commands change the current file context to a new location,
720*84d9c625SLionel Sambucbased on information found in the
721*84d9c625SLionel Sambuc@LI{tags}files.
722*84d9c625SLionel SambucIf you are unfamiliar with these commands,
723*84d9c625SLionel Sambucyou should review their description in the
724*84d9c625SLionel Sambuc@CO{ex}
725*84d9c625SLionel Sambuc and
726*84d9c625SLionel Sambuc@CO{vi}
727*84d9c625SLionel Sambuc commands section of this manual.
728*84d9c625SLionel SambucFor additional information on tags files,
729*84d9c625SLionel Sambucsee the discussion of the
730*84d9c625SLionel Sambuc@OP{tags}
731*84d9c625SLionel Sambucedit option and the system
732*84d9c625SLionel Sambuc@XR{ctags,1}
733*84d9c625SLionel Sambucmanual page.
734*84d9c625SLionel Sambuc
735*84d9c625SLionel SambucIn addition,
736*84d9c625SLionel Sambuc@CO{nvi}
737*84d9c625SLionel Sambuc supports the notion of
738*84d9c625SLionel Sambuc@QQ{tags stacks},
739*84d9c625SLionel Sambucusing the
740*84d9c625SLionel Sambuc@CO{<control-T>}
741*84d9c625SLionel Sambuc command.
742*84d9c625SLionel SambucThe
743*84d9c625SLionel Sambuc@CO{<control-T>}
744*84d9c625SLionel Sambuc command returns the user to the previous context, i.e.,
745*84d9c625SLionel Sambucthe last place from which a
746*84d9c625SLionel Sambuc@CO{<control-]>}
747*84d9c625SLionel Sambuc or
748*84d9c625SLionel Sambuc@CO{tag}
749*84d9c625SLionel Sambuccommand was entered.
750*84d9c625SLionel SambucThese three commands provide the basic functionality which allows you
751*84d9c625SLionel Sambucto use
752*84d9c625SLionel Sambuc@CO{vi}
753*84d9c625SLionel Sambuc to review source code in a structured manner.
754*84d9c625SLionel Sambuc
755*84d9c625SLionel Sambuc@CO{Nvi}
756*84d9c625SLionel Sambuc also provides two other basic
757*84d9c625SLionel Sambuc@CO{ex}
758*84d9c625SLionel Sambuc commands for tag support:
759*84d9c625SLionel Sambuc@CO{tagpop}
760*84d9c625SLionel Sambuc and
761*84d9c625SLionel Sambuc@CO{tagtop}  .
762*84d9c625SLionel SambucThe
763*84d9c625SLionel Sambuc@CO{tagpop}
764*84d9c625SLionel Sambuc command is identical to the
765*84d9c625SLionel Sambuc@CO{<control-T>}
766*84d9c625SLionel Sambuc command,
767*84d9c625SLionel Sambucwith the additional functionality that you may specify that modifications
768*84d9c625SLionel Sambucto the current file are to be discarded.
769*84d9c625SLionel SambucThis cannot be done using the
770*84d9c625SLionel Sambuc@CO{<control-T>}
771*84d9c625SLionel Sambuc command.
772*84d9c625SLionel SambucThe
773*84d9c625SLionel Sambuc@CO{tagtop}
774*84d9c625SLionel Sambuc command discards all of the contexts that have been pushed onto the tag
775*84d9c625SLionel Sambucstack, returning to the context from which the first
776*84d9c625SLionel Sambuc@CO{<control-]>}
777*84d9c625SLionel Sambuc or
778*84d9c625SLionel Sambuc@CO{tag}
779*84d9c625SLionel Sambuc command was entered.
780*84d9c625SLionel Sambuc
781*84d9c625SLionel SambucThe historic
782*84d9c625SLionel Sambuc@XR{ctags,1}
783*84d9c625SLionel Sambuctags file format supports only a single location per tag,
784*84d9c625SLionel Sambucnormally the function declaration or structure or string definition.
785*84d9c625SLionel SambucMore sophisticated source code tools often provide multiple locations
786*84d9c625SLionel Sambucper tag, e.g.,
787*84d9c625SLionel Sambuca list of the places from which a function is called or a string
788*84d9c625SLionel Sambucdefinition is used.
789*84d9c625SLionel SambucAn example of this functionality is the System V source code tool,
790*84d9c625SLionel Sambuc@CO{cscope}  .
791*84d9c625SLionel Sambuc@sp 1
792*84d9c625SLionel Sambuc@CO{Cscope}
793*84d9c625SLionel Sambuc creates a database of information on source code files,
794*84d9c625SLionel Sambucand supports a query language for that information as described in the
795*84d9c625SLionel Sambuc@XR{cscope,1}
796*84d9c625SLionel Sambucmanual page.
797*84d9c625SLionel Sambuc@CO{Nvi}
798*84d9c625SLionel Sambuc contains an interface to the
799*84d9c625SLionel Sambuc@CO{cscope}
800*84d9c625SLionel Sambuc query language which permits you to query
801*84d9c625SLionel Sambuc@CO{cscope}
802*84d9c625SLionel Sambuc and then sequentially step through the locations in the sources files which
803*84d9c625SLionel Sambuc@CO{cscope}
804*84d9c625SLionel Sambuc returns.
805*84d9c625SLionel SambucThere are two
806*84d9c625SLionel Sambuc@CO{nvi}
807*84d9c625SLionel Sambuc commands which support this ability to step through multiple locations.
808*84d9c625SLionel SambucThey are the
809*84d9c625SLionel Sambuc@CO{ex}
810*84d9c625SLionel Sambuc commands
811*84d9c625SLionel Sambuc@CO{tagnext}
812*84d9c625SLionel Sambuc and
813*84d9c625SLionel Sambuc@CO{tagprev}  .
814*84d9c625SLionel SambucThe
815*84d9c625SLionel Sambuc@CO{tagnext}
816*84d9c625SLionel Sambuc command moves to the next location for the current tag.
817*84d9c625SLionel SambucThe
818*84d9c625SLionel Sambuc@CO{tagprev}
819*84d9c625SLionel Sambuc command moves to the previous location for the current tag.
820*84d9c625SLionel Sambuc(See the
821*84d9c625SLionel Sambuc@CO{tagnext}
822*84d9c625SLionel Sambuc and
823*84d9c625SLionel Sambuc@CO{tagprev}
824*84d9c625SLionel Sambuc command discussion in the
825*84d9c625SLionel Sambuc@CO{ex}
826*84d9c625SLionel Sambuc commands section of this manual for more information.)
827*84d9c625SLionel SambucAt any time during this sequential walk,
828*84d9c625SLionel Sambucyou may use the
829*84d9c625SLionel Sambuc@CO{<control-]>}  ,
830*84d9c625SLionel Sambuc@CO{tag}
831*84d9c625SLionel Sambuc or
832*84d9c625SLionel Sambuc@CO{cscope}
833*84d9c625SLionel Sambuc commands to move to a new tag context, and then use the
834*84d9c625SLionel Sambuc@CO{<control-T>}
835*84d9c625SLionel Sambuc or
836*84d9c625SLionel Sambuc@CO{tagpop}
837*84d9c625SLionel Sambuc commands to return and continue stepping through the locations for this
838*84d9c625SLionel Sambuctag.
839*84d9c625SLionel SambucThis is similar to the previous model of a simple tag stack,
840*84d9c625SLionel Sambucexcept that each entry in the tag stack may have more than one file context
841*84d9c625SLionel Sambucthat is of interest.
842*84d9c625SLionel Sambuc
843*84d9c625SLionel SambucAlthough there is no widely distributed version of
844*84d9c625SLionel Sambuc@XR{ctags,1}
845*84d9c625SLionel Sambucthat creates tags files with multiple locations per tag,
846*84d9c625SLionel Sambuc@CO{nvi}
847*84d9c625SLionel Sambuc has been written to understand the obvious extension to the historic
848*84d9c625SLionel Sambuctags file format, i.e., more than a single line in the tags file with
849*84d9c625SLionel Sambucthe same initial tag name.
850*84d9c625SLionel SambucIf you wish to extend your
851*84d9c625SLionel Sambuc@CO{ctags}
852*84d9c625SLionel Sambucimplementation or other tool with which you build tags files,
853*84d9c625SLionel Sambucthis extension should be simple and will require no changes to
854*84d9c625SLionel Sambuc@CO{nvi}  .
855*84d9c625SLionel Sambuc
856*84d9c625SLionel SambucThe
857*84d9c625SLionel Sambuc@CO{nvi}
858*84d9c625SLionel Sambuc and
859*84d9c625SLionel Sambuc@CO{cscope}
860*84d9c625SLionel Sambuc interface is based on the new
861*84d9c625SLionel Sambuc@CO{ex}
862*84d9c625SLionel Sambuc command
863*84d9c625SLionel Sambuc@CO{cscope}  ,
864*84d9c625SLionel Sambucwhich has five subcommands:
865*84d9c625SLionel Sambuc@CO{add}  ,
866*84d9c625SLionel Sambuc@CO{find}  ,
867*84d9c625SLionel Sambuc@CO{help}  ,
868*84d9c625SLionel Sambuc@CO{kill}
869*84d9c625SLionel Sambuc and
870*84d9c625SLionel Sambuc@CO{reset}  .
871*84d9c625SLionel SambucThe subcommand
872*84d9c625SLionel Sambuc@CO{find}
873*84d9c625SLionel Sambuc itself has eight subcommands:
874*84d9c625SLionel Sambuc@CO{c}  ,
875*84d9c625SLionel Sambuc@CO{d}  ,
876*84d9c625SLionel Sambuc@CO{e}  ,
877*84d9c625SLionel Sambuc@CO{f}  ,
878*84d9c625SLionel Sambuc@CO{g}  ,
879*84d9c625SLionel Sambuc@CO{i}  ,
880*84d9c625SLionel Sambuc@CO{s}
881*84d9c625SLionel Sambuc and
882*84d9c625SLionel Sambuc@CO{t}  .
883*84d9c625SLionel Sambuc
884*84d9c625SLionel Sambuc@itemize @bullet
885*84d9c625SLionel Sambuc@IP{cs[cope] a[dd] file}
886*84d9c625SLionel Sambuc
887*84d9c625SLionel SambucThe
888*84d9c625SLionel Sambuc@CO{add}
889*84d9c625SLionel Sambuc command attaches to the specified
890*84d9c625SLionel Sambuc@CO{cscope}
891*84d9c625SLionel Sambuc database.
892*84d9c625SLionel SambucThe file name is expanded using the standard filename expansions.
893*84d9c625SLionel SambucIf
894*84d9c625SLionel Sambuc@CO{file}
895*84d9c625SLionel Sambuc is a directory, the file
896*84d9c625SLionel Sambuc@QQ{cscope.out}
897*84d9c625SLionel Sambucin that directory is used as the database.
898*84d9c625SLionel Sambuc
899*84d9c625SLionel SambucAfter
900*84d9c625SLionel Sambuc@CO{nvi}
901*84d9c625SLionel Sambuc attaches to a new database,
902*84d9c625SLionel Sambucall subsequent
903*84d9c625SLionel Sambuc@CO{cscope}
904*84d9c625SLionel Sambuc queries will be asked of that database.
905*84d9c625SLionel SambucThe result of any single query is the collection of response to the query
906*84d9c625SLionel Sambucfrom all of the attached databases.
907*84d9c625SLionel Sambuc@sp 1
908*84d9c625SLionel SambucIf the
909*84d9c625SLionel Sambuc@QQ{CSCOPE_DIRS}
910*84d9c625SLionel Sambucenvironmental variable is set when
911*84d9c625SLionel Sambuc@CO{nvi}
912*84d9c625SLionel Sambuc is run,
913*84d9c625SLionel Sambucit is expected to be a <colon> or <blank>-separated list of
914*84d9c625SLionel Sambuc@CO{cscope}
915*84d9c625SLionel Sambuc databases or directories containing
916*84d9c625SLionel Sambuc@CO{cscope}
917*84d9c625SLionel Sambuc databases, to which the user wishes to attach.
918*84d9c625SLionel Sambuc@IP{:cs[cope] f[ind] c|d|e|f|g|i|s|t buffer|pattern}
919*84d9c625SLionel Sambuc
920*84d9c625SLionel SambucThe
921*84d9c625SLionel Sambuc@CO{find}
922*84d9c625SLionel Sambuc command is the
923*84d9c625SLionel Sambuc@CO{cscope}
924*84d9c625SLionel Sambuc query command for
925*84d9c625SLionel Sambuc@CO{nvi}  .
926*84d9c625SLionel SambucFor this command,
927*84d9c625SLionel Sambuc@CO{nvi}
928*84d9c625SLionel Sambuc queries all attached
929*84d9c625SLionel Sambuc@CO{cscope}
930*84d9c625SLionel Sambuc databases for the pattern.
931*84d9c625SLionel SambucIf the pattern is a double-quote character followed by a valid buffer
932*84d9c625SLionel Sambucname (e.g.,
933*84d9c625SLionel Sambuc@LI{}"<character>" ),
934*84d9c625SLionel Sambucthen the contents of the named buffer are used as the pattern.
935*84d9c625SLionel SambucOtherwise, the pattern is a Regular Expression.
936*84d9c625SLionel Sambuc@sp 1
937*84d9c625SLionel SambucThe
938*84d9c625SLionel Sambuc@CO{find}
939*84d9c625SLionel Sambuc command pushes the current location onto the tags stack,
940*84d9c625SLionel Sambucand switches to the first location resulting from the query,
941*84d9c625SLionel Sambucif the query returned at least one result.
942*84d9c625SLionel Sambuc@sp 1
943*84d9c625SLionel SambucFile names returned by the
944*84d9c625SLionel Sambuc@CO{cscope}
945*84d9c625SLionel Sambuc query, if not absolute paths, are searched for relative to the directory
946*84d9c625SLionel Sambucwhere the
947*84d9c625SLionel Sambuc@CO{cscope}
948*84d9c625SLionel Sambuc database is located.
949*84d9c625SLionel SambucIn addition, if the file
950*84d9c625SLionel Sambuc@QQ{cscope.tpath}
951*84d9c625SLionel Sambucappears in the same directory as the
952*84d9c625SLionel Sambuc@CO{cscope}
953*84d9c625SLionel Sambuc database,
954*84d9c625SLionel Sambucit is expected to contain a colon-separated list of directory names
955*84d9c625SLionel Sambucwhere files referenced by its associated
956*84d9c625SLionel Sambuc@CO{cscope}
957*84d9c625SLionel Sambuc database may be found.
958*84d9c625SLionel Sambuc@sp 1
959*84d9c625SLionel SambucThe
960*84d9c625SLionel Sambuc@CO{find}
961*84d9c625SLionel Sambuc subcommand is one of the following:
962*84d9c625SLionel Sambuc@table @asis
963*84d9c625SLionel Sambuc@item c
964*84d9c625SLionel SambucFind callers of the name.
965*84d9c625SLionel Sambuc@item d
966*84d9c625SLionel SambucFind all function calls made from name.
967*84d9c625SLionel Sambuc@item e
968*84d9c625SLionel SambucFind pattern.
969*84d9c625SLionel Sambuc@item f
970*84d9c625SLionel SambucFind files with name as substring.
971*84d9c625SLionel Sambuc@item g
972*84d9c625SLionel SambucFind definition of name.
973*84d9c625SLionel Sambuc@item i
974*84d9c625SLionel SambucFind files #including name.
975*84d9c625SLionel Sambuc@item s
976*84d9c625SLionel SambucFind all uses of name.
977*84d9c625SLionel Sambuc@item t
978*84d9c625SLionel SambucFind assignments to name.
979*84d9c625SLionel Sambuc@end table
980*84d9c625SLionel Sambuc@IP{:cs[cope] h[elp] [command]}
981*84d9c625SLionel Sambuc
982*84d9c625SLionel SambucList the
983*84d9c625SLionel Sambuc@CO{cscope}
984*84d9c625SLionel Sambuc commands,
985*84d9c625SLionel Sambucor optionally list usage help for any single
986*84d9c625SLionel Sambuc@CO{cscope}
987*84d9c625SLionel Sambuc command.
988*84d9c625SLionel Sambuc@IP{:display c[onnections]}
989*84d9c625SLionel Sambuc
990*84d9c625SLionel SambucDisplay the list of
991*84d9c625SLionel Sambuc@CO{cscope}
992*84d9c625SLionel Sambuc databases to which
993*84d9c625SLionel Sambuc@CO{nvi}
994*84d9c625SLionel Sambuc is currently connected.
995*84d9c625SLionel Sambuc@IP{:cs[cope] k[ill] #}
996*84d9c625SLionel Sambuc
997*84d9c625SLionel SambucDisconnect from a specific
998*84d9c625SLionel Sambuc@CO{cscope}
999*84d9c625SLionel Sambuc database.
1000*84d9c625SLionel SambucThe connection number is the one displayed by the
1001*84d9c625SLionel Sambuc@CO{ex}
1002*84d9c625SLionel Sambuc @CO{display connections}
1003*84d9c625SLionel Sambuccommand.
1004*84d9c625SLionel Sambuc@IP{:cs[cope] r[eset]}
1005*84d9c625SLionel Sambuc
1006*84d9c625SLionel SambucDisconnect from all attached
1007*84d9c625SLionel Sambuc@CO{cscope}
1008*84d9c625SLionel Sambuc databases.
1009*84d9c625SLionel Sambuc@end itemize
1010*84d9c625SLionel Sambuc
1011*84d9c625SLionel SambucCscope is not freely redistributable software,
1012*84d9c625SLionel Sambucbut is fairly inexpensive and easily available.
1013*84d9c625SLionel SambucTo purchase a copy of
1014*84d9c625SLionel Sambuc@CO{cscope}  ,
1015*84d9c625SLionel Sambucsee http://www.att.com/ssg/products/toolchest.html.
1016*84d9c625SLionel Sambuc@chapter Regular Expressions and Replacement Strings
1017*84d9c625SLionel Sambuc
1018*84d9c625SLionel SambucRegular expressions are used in line addresses,
1019*84d9c625SLionel Sambucas the first part of the
1020*84d9c625SLionel Sambuc@CO{ex}
1021*84d9c625SLionel Sambuc @CO{substitute}  ,
1022*84d9c625SLionel Sambuc@CO{global}  ,
1023*84d9c625SLionel Sambucand
1024*84d9c625SLionel Sambuc@CO{v}
1025*84d9c625SLionel Sambuc commands, and in search patterns.
1026*84d9c625SLionel Sambuc
1027*84d9c625SLionel SambucThe regular expressions supported by
1028*84d9c625SLionel Sambuc@EV{ex,vi}
1029*84d9c625SLionel Sambucare, by default, the Basic Regular Expressions (BRE's) described in the
1030*84d9c625SLionel SambucIEEE POSIX Standard 1003.2.
1031*84d9c625SLionel SambucThe
1032*84d9c625SLionel Sambuc@OP{extended}
1033*84d9c625SLionel Sambucoption causes all regular expressions to be interpreted as the Extended
1034*84d9c625SLionel SambucRegular Expressions (ERE's) described by the same standard.
1035*84d9c625SLionel Sambuc(See
1036*84d9c625SLionel Sambuc@XR{re_format,7}
1037*84d9c625SLionel Sambucfor more information.)
1038*84d9c625SLionel SambucGenerally speaking, BRE's are the Regular Expressions found in
1039*84d9c625SLionel Sambuc@XR{ed,1}
1040*84d9c625SLionel Sambucand
1041*84d9c625SLionel Sambuc@XR{grep,1},
1042*84d9c625SLionel Sambucand ERE's are the Regular Expressions found in
1043*84d9c625SLionel Sambuc@XR{egrep,1}.
1044*84d9c625SLionel Sambuc
1045*84d9c625SLionel SambucThe following is not intended to provide a description of Regular
1046*84d9c625SLionel SambucExpressions.
1047*84d9c625SLionel SambucThe information here only describes strings and characters which
1048*84d9c625SLionel Sambuchave special meanings in the
1049*84d9c625SLionel Sambuc@EV{ex,vi}
1050*84d9c625SLionel Sambucversion of RE's,
1051*84d9c625SLionel Sambucor options which change the meanings of characters that normally
1052*84d9c625SLionel Sambuchave special meanings in RE's.
1053*84d9c625SLionel Sambuc@enumerate
1054*84d9c625SLionel Sambuc@item
1055*84d9c625SLionel SambucAn empty RE (e.g.
1056*84d9c625SLionel Sambuc@QT{//}
1057*84d9c625SLionel Sambucor
1058*84d9c625SLionel Sambuc@QT{??}
1059*84d9c625SLionel Sambucis equivalent to the last RE used.
1060*84d9c625SLionel Sambuc@item
1061*84d9c625SLionel SambucThe construct
1062*84d9c625SLionel Sambuc@QT{\e<}
1063*84d9c625SLionel Sambucmatches the beginning of a word.
1064*84d9c625SLionel Sambuc@item
1065*84d9c625SLionel SambucThe construct
1066*84d9c625SLionel Sambuc@QT{\e>}
1067*84d9c625SLionel Sambucmatches the end of a word.
1068*84d9c625SLionel Sambuc@item
1069*84d9c625SLionel SambucThe character
1070*84d9c625SLionel Sambuc@QT{~}
1071*84d9c625SLionel Sambucmatches the replacement part of the last
1072*84d9c625SLionel Sambuc@CO{substitute}
1073*84d9c625SLionel Sambuc command.
1074*84d9c625SLionel Sambuc@end enumerate
1075*84d9c625SLionel Sambuc
1076*84d9c625SLionel SambucWhen the
1077*84d9c625SLionel Sambuc@OP{magic}
1078*84d9c625SLionel Sambucoption is
1079*84d9c625SLionel Sambuc@emph{not}
1080*84d9c625SLionel Sambucset, the only characters with special meanings are a
1081*84d9c625SLionel Sambuc@QT{^}
1082*84d9c625SLionel Sambuccharacter at the beginning of an RE, a
1083*84d9c625SLionel Sambuc@QT{$}
1084*84d9c625SLionel Sambuccharacter at the end of an RE, and the escaping character
1085*84d9c625SLionel Sambuc@QT{\e}.
1086*84d9c625SLionel SambucThe characters
1087*84d9c625SLionel Sambuc@QT{.},
1088*84d9c625SLionel Sambuc@QT{*},
1089*84d9c625SLionel Sambuc@QT{[}
1090*84d9c625SLionel Sambucand
1091*84d9c625SLionel Sambuc@QT{~}
1092*84d9c625SLionel Sambucare treated as ordinary characters unless preceded by a
1093*84d9c625SLionel Sambuc@QT{\e};
1094*84d9c625SLionel Sambucwhen preceded by a
1095*84d9c625SLionel Sambuc@QT{\e}
1096*84d9c625SLionel Sambucthey regain their special meaning.
1097*84d9c625SLionel Sambuc
1098*84d9c625SLionel SambucReplacement strings are the second part of a
1099*84d9c625SLionel Sambuc@CO{substitute}
1100*84d9c625SLionel Sambuc command.
1101*84d9c625SLionel Sambuc
1102*84d9c625SLionel SambucThe character
1103*84d9c625SLionel Sambuc@QT{&}
1104*84d9c625SLionel Sambuc(or
1105*84d9c625SLionel Sambuc@QT{\e&}
1106*84d9c625SLionel Sambucif the
1107*84d9c625SLionel Sambuc@OP{magic}
1108*84d9c625SLionel Sambucoption is
1109*84d9c625SLionel Sambuc@emph{not}
1110*84d9c625SLionel Sambucset) in the replacement string stands for the text matched by the RE
1111*84d9c625SLionel Sambucthat is being replaced.
1112*84d9c625SLionel SambucThe character
1113*84d9c625SLionel Sambuc@QT{~}
1114*84d9c625SLionel Sambuc(or
1115*84d9c625SLionel Sambuc@QT{\e~}
1116*84d9c625SLionel Sambucif the
1117*84d9c625SLionel Sambuc@OP{magic}
1118*84d9c625SLionel Sambucoption is
1119*84d9c625SLionel Sambuc@emph{not}
1120*84d9c625SLionel Sambucset) stands for the replacement part of the previous
1121*84d9c625SLionel Sambuc@CO{substitute}
1122*84d9c625SLionel Sambuc command.
1123*84d9c625SLionel SambucIt is only valid after a
1124*84d9c625SLionel Sambuc@CO{substitute}
1125*84d9c625SLionel Sambuc command has been performed.
1126*84d9c625SLionel Sambuc
1127*84d9c625SLionel SambucThe string
1128*84d9c625SLionel Sambuc@QT{\e#},
1129*84d9c625SLionel Sambucwhere
1130*84d9c625SLionel Sambuc@QT{#}
1131*84d9c625SLionel Sambucis an integer value from 1 to 9, stands for the text matched by
1132*84d9c625SLionel Sambucthe portion of the RE enclosed in the
1133*84d9c625SLionel Sambuc@QT{#}'th
1134*84d9c625SLionel Sambucset of escaped parentheses, e.g.
1135*84d9c625SLionel Sambuc@QT{\e(}
1136*84d9c625SLionel Sambucand
1137*84d9c625SLionel Sambuc@QT{\e)}.
1138*84d9c625SLionel SambucFor example,
1139*84d9c625SLionel Sambuc@QT{s/abc\e(.*\e)def/\e1/}
1140*84d9c625SLionel Sambucdeletes the strings
1141*84d9c625SLionel Sambuc@QT{abc}
1142*84d9c625SLionel Sambucand
1143*84d9c625SLionel Sambuc@QT{def}
1144*84d9c625SLionel Sambucfrom the matched pattern.
1145*84d9c625SLionel Sambuc
1146*84d9c625SLionel SambucThe strings
1147*84d9c625SLionel Sambuc@QT{\el},
1148*84d9c625SLionel Sambuc@QT{\eu},
1149*84d9c625SLionel Sambuc@QT{\eL}
1150*84d9c625SLionel Sambucand
1151*84d9c625SLionel Sambuc@QT{\eU}
1152*84d9c625SLionel Sambuccan be used to modify the case of elements in the replacement string.
1153*84d9c625SLionel SambucThe string
1154*84d9c625SLionel Sambuc@QT{\el}
1155*84d9c625SLionel Sambuccauses the next character to be converted to lowercase;
1156*84d9c625SLionel Sambucthe string
1157*84d9c625SLionel Sambuc@QT{\eu}
1158*84d9c625SLionel Sambucbehaves similarly, but converts to uppercase
1159*84d9c625SLionel Sambuc(e.g.
1160*84d9c625SLionel Sambuc@LI{s/abc/\eU&/}replaces the string
1161*84d9c625SLionel Sambuc@LI{abc}with
1162*84d9c625SLionel Sambuc@LI{ABC}).
1163*84d9c625SLionel SambucThe string
1164*84d9c625SLionel Sambuc@QT{\eL}
1165*84d9c625SLionel Sambuccauses characters up to the end of the string or the next occurrence
1166*84d9c625SLionel Sambucof the strings
1167*84d9c625SLionel Sambuc@QT{\ee}
1168*84d9c625SLionel Sambucor
1169*84d9c625SLionel Sambuc@QT{\eE}
1170*84d9c625SLionel Sambucto be converted to lowercase;
1171*84d9c625SLionel Sambucthe string
1172*84d9c625SLionel Sambuc@QT{\eU}
1173*84d9c625SLionel Sambucbehaves similarly, but converts to uppercase.
1174*84d9c625SLionel Sambuc
1175*84d9c625SLionel SambucIf the entire replacement pattern is
1176*84d9c625SLionel Sambuc@QT{%},
1177*84d9c625SLionel Sambucthen the last replacement pattern is used again.
1178*84d9c625SLionel Sambuc
1179*84d9c625SLionel SambucIn
1180*84d9c625SLionel Sambuc@CO{vi}  ,
1181*84d9c625SLionel Sambucinserting a
1182*84d9c625SLionel Sambuc@LI{<control-M>}into the replacement string will cause
1183*84d9c625SLionel Sambucthe matched line to be split into two lines at that point.
1184*84d9c625SLionel Sambuc(The
1185*84d9c625SLionel Sambuc@LI{<control-M>}will be discarded.)
1186*84d9c625SLionel Sambuc@chapter Scripting Languages
1187*84d9c625SLionel Sambuc
1188*84d9c625SLionel SambucThe
1189*84d9c625SLionel Sambuc@CO{nvi}
1190*84d9c625SLionel Sambuc editor currently supports two scripting languages, Tcl/Tk and Perl.
1191*84d9c625SLionel Sambuc(Note that Perl4 isn't sufficient, and that the Perl5 used must be
1192*84d9c625SLionel Sambucversion 5.002 or later.
1193*84d9c625SLionel SambucSee the
1194*84d9c625SLionel Sambuc@QB{Building Nvi}
1195*84d9c625SLionel Sambucsection for more information.
1196*84d9c625SLionel Sambuc
1197*84d9c625SLionel SambucThe scripting language interface is still being worked on,
1198*84d9c625SLionel Sambuctherefore the following information is probably incomplete,
1199*84d9c625SLionel Sambucprobably wrong in cases, and likely to change.
1200*84d9c625SLionel SambucSee the
1201*84d9c625SLionel Sambuc@LI{perl_api}and
1202*84d9c625SLionel Sambuc@LI{tcl_api}source directories for more information.
1203*84d9c625SLionel SambucAs a quick reference, the following function calls are provided for
1204*84d9c625SLionel Sambucboth the Perl and Tcl interfaces.
1205*84d9c625SLionel SambucThe Perl interface uses a slightly different naming convention,
1206*84d9c625SLionel Sambuce.g. ``viFindScreen'' is named ``VI::FindScreen''.
1207*84d9c625SLionel Sambuc@itemize @bullet
1208*84d9c625SLionel Sambuc@IP{viFindScreen file}
1209*84d9c625SLionel Sambuc
1210*84d9c625SLionel SambucReturn the
1211*84d9c625SLionel Sambuc@LI{screenId}associated with
1212*84d9c625SLionel Sambuc@LI{file}.
1213*84d9c625SLionel Sambuc@IP{viAppendLine screenId lineNumber text}
1214*84d9c625SLionel Sambuc
1215*84d9c625SLionel SambucAppend
1216*84d9c625SLionel Sambuc@LI{text}as a new line after line number
1217*84d9c625SLionel Sambuc@LI{lineNumber},
1218*84d9c625SLionel Sambucin the screen
1219*84d9c625SLionel Sambuc@LI{screenId}.
1220*84d9c625SLionel Sambuc@IP{viDelLine screenId lineNum}
1221*84d9c625SLionel Sambuc
1222*84d9c625SLionel SambucDelete the line
1223*84d9c625SLionel Sambuc@LI{lineNumber}from the screen
1224*84d9c625SLionel Sambuc@LI{screenId}.
1225*84d9c625SLionel Sambuc@IP{viGetLine screenId lineNumber}
1226*84d9c625SLionel Sambuc
1227*84d9c625SLionel SambucReturn the line
1228*84d9c625SLionel Sambuc@LI{lineNumber}from the screen
1229*84d9c625SLionel Sambuc@LI{screenId}.
1230*84d9c625SLionel Sambuc@IP{viInsertLine screenId lineNumber text}
1231*84d9c625SLionel Sambuc
1232*84d9c625SLionel SambucInsert
1233*84d9c625SLionel Sambuc@LI{text}as a new line before line number
1234*84d9c625SLionel Sambuc@LI{lineNumber}in the screen
1235*84d9c625SLionel Sambuc@LI{screenId}.
1236*84d9c625SLionel Sambuc@IP{viLastLine screenId}
1237*84d9c625SLionel Sambuc
1238*84d9c625SLionel SambucReturn the line number of the last line in the screen
1239*84d9c625SLionel Sambuc@LI{screenId}.
1240*84d9c625SLionel Sambuc@IP{viSetLine screenId lineNumber text}
1241*84d9c625SLionel Sambuc
1242*84d9c625SLionel SambucChange the line
1243*84d9c625SLionel Sambuc@LI{lineNumber}in the screen
1244*84d9c625SLionel Sambuc@LI{screenId}to match the specified
1245*84d9c625SLionel Sambuc@LI{text}.
1246*84d9c625SLionel Sambuc@IP{viGetMark screenId mark}
1247*84d9c625SLionel Sambuc
1248*84d9c625SLionel SambucReturn the current line and column for the specified
1249*84d9c625SLionel Sambuc@LI{mark}from the screen
1250*84d9c625SLionel Sambuc@LI{screenId}.
1251*84d9c625SLionel Sambuc@IP{viSetMark screenId mark line column}
1252*84d9c625SLionel Sambuc
1253*84d9c625SLionel SambucSet the specified
1254*84d9c625SLionel Sambuc@LI{mark}to be at line
1255*84d9c625SLionel Sambuc@LI{line},
1256*84d9c625SLionel Sambuccolumn
1257*84d9c625SLionel Sambuc@LI{column},
1258*84d9c625SLionel Sambucin the screen
1259*84d9c625SLionel Sambuc@LI{screenId}.
1260*84d9c625SLionel Sambuc@IP{viGetCursor screenId}
1261*84d9c625SLionel Sambuc
1262*84d9c625SLionel SambucReturn the current line and column for the cursor in the screen
1263*84d9c625SLionel Sambuc@LI{screenId}.
1264*84d9c625SLionel Sambuc@IP{viSetCursor screenId line column}
1265*84d9c625SLionel Sambuc
1266*84d9c625SLionel SambucSet the cursor in the screen
1267*84d9c625SLionel Sambuc@LI{screenId}to the specified
1268*84d9c625SLionel Sambuc@LI{line}and
1269*84d9c625SLionel Sambuc@LI{column}.
1270*84d9c625SLionel Sambuc@IP{viMsg screenId text}
1271*84d9c625SLionel Sambuc
1272*84d9c625SLionel SambucDisplay the specified
1273*84d9c625SLionel Sambuc@LI{text}as a vi message in the screen
1274*84d9c625SLionel Sambuc@LI{screenId}.
1275*84d9c625SLionel Sambuc@IP{viNewScreen screenId [file]}
1276*84d9c625SLionel Sambuc
1277*84d9c625SLionel SambucCreate a new screen.
1278*84d9c625SLionel Sambuc@IP{viEndScreen screenId}
1279*84d9c625SLionel Sambuc
1280*84d9c625SLionel SambucExit the screen
1281*84d9c625SLionel Sambuc@LI{screenId}.
1282*84d9c625SLionel Sambuc@IP{viSwitchScreen screenId screenId}
1283*84d9c625SLionel Sambuc
1284*84d9c625SLionel SambucSwitch from the screen
1285*84d9c625SLionel Sambuc@LI{screenId}to the screen
1286*84d9c625SLionel Sambuc@LI{screenId}.
1287*84d9c625SLionel Sambuc@IP{viMapKey screenId key tclproc}
1288*84d9c625SLionel Sambuc
1289*84d9c625SLionel SambucMap the specified
1290*84d9c625SLionel Sambuc@LI{key}in the screen
1291*84d9c625SLionel Sambuc@LI{screenId}to the Tcl procedure
1292*84d9c625SLionel Sambuc@LI{tclproc}.
1293*84d9c625SLionel Sambuc@IP{viUnmMapKey screenId key}
1294*84d9c625SLionel Sambuc
1295*84d9c625SLionel SambucUnmap the specified
1296*84d9c625SLionel Sambuc@LI{key}in the screen
1297*84d9c625SLionel Sambuc@LI{screenId}@IP{viGetOpt screenId option}
1298*84d9c625SLionel Sambuc
1299*84d9c625SLionel SambucReturn the value of the specified
1300*84d9c625SLionel Sambuc@LI{option}from the screen
1301*84d9c625SLionel Sambuc@LI{screenId}.
1302*84d9c625SLionel Sambuc@IP{viSetOpt screenId command}
1303*84d9c625SLionel Sambuc
1304*84d9c625SLionel SambucSet one or more options in the screen
1305*84d9c625SLionel Sambuc@LI{screenId}.
1306*84d9c625SLionel Sambuc@end itemize
1307*84d9c625SLionel Sambuc@chapter General Editor Description
1308*84d9c625SLionel Sambuc
1309*84d9c625SLionel SambucWhen
1310*84d9c625SLionel Sambuc@CO{ex}
1311*84d9c625SLionel Sambuc or
1312*84d9c625SLionel Sambuc@CO{vi}
1313*84d9c625SLionel Sambuc are executed,
1314*84d9c625SLionel Sambucthe text of a file is read (or a temporary file is created),
1315*84d9c625SLionel Sambucand then all editing changes happen within the context of the
1316*84d9c625SLionel Sambuccopy of the file.
1317*84d9c625SLionel Sambuc@emph{No changes affect the actual file until the file is written out},
1318*84d9c625SLionel Sambuceither using a write command or another command which is affected by the
1319*84d9c625SLionel Sambuc@OP{autowrite}
1320*84d9c625SLionel Sambucoption.
1321*84d9c625SLionel Sambuc
1322*84d9c625SLionel SambucAll files are locked (using the
1323*84d9c625SLionel Sambuc@XR{flock,2}
1324*84d9c625SLionel Sambucor
1325*84d9c625SLionel Sambuc@XR{fcntl,2}
1326*84d9c625SLionel Sambucinterfaces) during the edit session,
1327*84d9c625SLionel Sambucto avoid inadvertently making modifications to multiple copies of the file.
1328*84d9c625SLionel SambucIf a lock cannot be obtained for a file because it is locked by another
1329*84d9c625SLionel Sambucprocess, the edit session is read-only (as if the
1330*84d9c625SLionel Sambuc@OP{readonly}
1331*84d9c625SLionel Sambucoption or the
1332*84d9c625SLionel Sambuc@strong{-R}
1333*84d9c625SLionel Sambucflag had been specified).
1334*84d9c625SLionel SambucIf a lock cannot be obtained for other reasons, the edit session will
1335*84d9c625SLionel Sambuccontinue, but the file status information
1336*84d9c625SLionel Sambuc(see the
1337*84d9c625SLionel Sambuc@CO{<control-G>}
1338*84d9c625SLionel Sambuc command) will reflect this fact.
1339*84d9c625SLionel Sambuc
1340*84d9c625SLionel SambucBoth
1341*84d9c625SLionel Sambuc@CO{ex}
1342*84d9c625SLionel Sambuc and
1343*84d9c625SLionel Sambuc@CO{vi}
1344*84d9c625SLionel Sambuc are modeful editors, i.e.@: they have two modes,
1345*84d9c625SLionel Sambuc@QQ{command}
1346*84d9c625SLionel Sambucmode and
1347*84d9c625SLionel Sambuc@QQ{text input}
1348*84d9c625SLionel Sambucmode.
1349*84d9c625SLionel SambucThe former is intended to permit you to enter commands which modifies
1350*84d9c625SLionel Sambucalready existing text.
1351*84d9c625SLionel SambucThe latter is intended to permit you to enter new text.
1352*84d9c625SLionel SambucWhen
1353*84d9c625SLionel Sambuc@CO{ex}
1354*84d9c625SLionel Sambuc first starts running, it is in command mode, and usually displays a prompt
1355*84d9c625SLionel Sambuc(see the
1356*84d9c625SLionel Sambuc@OP{prompt}
1357*84d9c625SLionel Sambucoption for more information).
1358*84d9c625SLionel SambucThe prompt is a single colon
1359*84d9c625SLionel Sambuc@PQ{:}
1360*84d9c625SLionel Sambuccharacter.
1361*84d9c625SLionel SambucThere are three commands that switch
1362*84d9c625SLionel Sambuc@CO{ex}
1363*84d9c625SLionel Sambuc into text input mode:
1364*84d9c625SLionel Sambuc@CO{append}  ,
1365*84d9c625SLionel Sambuc@CO{change}
1366*84d9c625SLionel Sambuc and
1367*84d9c625SLionel Sambuc@CO{insert}  .
1368*84d9c625SLionel SambucOnce in input mode, entering a line containing only a single period
1369*84d9c625SLionel Sambuc@PQ{.}
1370*84d9c625SLionel Sambucends text input mode and returns to command mode,
1371*84d9c625SLionel Sambucwhere the prompt is redisplayed.
1372*84d9c625SLionel Sambuc
1373*84d9c625SLionel SambucWhen
1374*84d9c625SLionel Sambuc@CO{vi}
1375*84d9c625SLionel Sambuc first starts running, it is in command mode as well.
1376*84d9c625SLionel SambucThere are eleven commands that switch
1377*84d9c625SLionel Sambuc@CO{vi}
1378*84d9c625SLionel Sambuc into text input mode:
1379*84d9c625SLionel Sambuc@CO{A}  ,
1380*84d9c625SLionel Sambuc@CO{a}  ,
1381*84d9c625SLionel Sambuc@CO{C}  ,
1382*84d9c625SLionel Sambuc@CO{c}  ,
1383*84d9c625SLionel Sambuc@CO{I}  ,
1384*84d9c625SLionel Sambuc@CO{i}  ,
1385*84d9c625SLionel Sambuc@CO{O}  ,
1386*84d9c625SLionel Sambuc@CO{o}  ,
1387*84d9c625SLionel Sambuc@CO{R}  ,
1388*84d9c625SLionel Sambuc@CO{S}
1389*84d9c625SLionel Sambuc and
1390*84d9c625SLionel Sambuc@CO{s}  .
1391*84d9c625SLionel SambucOnce in input mode, entering an
1392*84d9c625SLionel Sambuc@LI{<escape>}character ends text input mode and returns to command mode.
1393*84d9c625SLionel Sambuc
1394*84d9c625SLionel Sambuc@EV{Ex,vi}
1395*84d9c625SLionel Sambucpresent three different interfaces to editing a file.
1396*84d9c625SLionel Sambuc@CO{Ex}
1397*84d9c625SLionel Sambuc presents a line oriented interface.
1398*84d9c625SLionel Sambuc@CO{Vi}
1399*84d9c625SLionel Sambuc presents a full screen display oriented interface,
1400*84d9c625SLionel Sambucalso known as
1401*84d9c625SLionel Sambuc@QQ{visual mode}.
1402*84d9c625SLionel SambucIn addition, there is a third mode,
1403*84d9c625SLionel Sambuc@QQ{open mode},
1404*84d9c625SLionel Sambucwhich is line oriented,
1405*84d9c625SLionel Sambucbut supports cursor movement and editing within the displayed line,
1406*84d9c625SLionel Sambucsimilarly to visual mode.
1407*84d9c625SLionel SambucOpen mode is not yet implemented in
1408*84d9c625SLionel Sambuc@CO{nvi}  .
1409*84d9c625SLionel Sambuc
1410*84d9c625SLionel SambucThe following words have special meanings in both the
1411*84d9c625SLionel Sambuc@CO{ex}
1412*84d9c625SLionel Sambuc and
1413*84d9c625SLionel Sambuc@CO{vi}
1414*84d9c625SLionel Sambuc command descriptions:
1415*84d9c625SLionel Sambuc@itemize @bullet
1416*84d9c625SLionel Sambuc@cindex <interrupt>
1417*84d9c625SLionel Sambuc@IP{<interrupt>}
1418*84d9c625SLionel Sambuc
1419*84d9c625SLionel SambucThe interrupt character is used to interrupt the current operation.
1420*84d9c625SLionel SambucNormally
1421*84d9c625SLionel Sambuc@LI{<control-C>},
1422*84d9c625SLionel Sambucwhatever character is set for the current terminal is used.
1423*84d9c625SLionel Sambuc@cindex "<literal-next>"
1424*84d9c625SLionel Sambuc@IP{<literal-next>}
1425*84d9c625SLionel Sambuc
1426*84d9c625SLionel SambucThe literal next character is used to escape the subsequent character
1427*84d9c625SLionel Sambucfrom any special meaning.
1428*84d9c625SLionel SambucThis character is always
1429*84d9c625SLionel Sambuc@LI{<control-V>}.
1430*84d9c625SLionel SambucIf the terminal is not set up to do XON/XOFF flow control,
1431*84d9c625SLionel Sambucthen
1432*84d9c625SLionel Sambuc@LI{<control-Q>}is used to mean literal next as well.
1433*84d9c625SLionel Sambuc@cindex "current pathname"
1434*84d9c625SLionel Sambuc@IP{current pathname}
1435*84d9c625SLionel Sambuc
1436*84d9c625SLionel SambucThe pathname of the file currently being edited by vi.
1437*84d9c625SLionel SambucWhen the percent character
1438*84d9c625SLionel Sambuc@PQ{%}
1439*84d9c625SLionel Sambucappears in a file name entered as part of an
1440*84d9c625SLionel Sambuc@CO{ex}
1441*84d9c625SLionel Sambuc command argument, it is replaced by the current pathname.
1442*84d9c625SLionel Sambuc(The
1443*84d9c625SLionel Sambuc@QT{%}
1444*84d9c625SLionel Sambuccharacter can be escaped by preceding it with a backslash.)
1445*84d9c625SLionel Sambuc@cindex "alternate pathname"
1446*84d9c625SLionel Sambuc@IP{alternate pathname}
1447*84d9c625SLionel Sambuc
1448*84d9c625SLionel SambucThe name of the last file name mentioned in an
1449*84d9c625SLionel Sambuc@CO{ex}
1450*84d9c625SLionel Sambuc command, or,
1451*84d9c625SLionel Sambucthe previous current pathname if the last file mentioned
1452*84d9c625SLionel Sambucbecomes the current file.
1453*84d9c625SLionel SambucWhen the hash mark character
1454*84d9c625SLionel Sambuc@PQ{#}
1455*84d9c625SLionel Sambucappears in a file name entered as part of an
1456*84d9c625SLionel Sambuc@CO{ex}
1457*84d9c625SLionel Sambuc command argument, it is replaced by the alternate pathname.
1458*84d9c625SLionel Sambuc(The
1459*84d9c625SLionel Sambuc@QT{#}
1460*84d9c625SLionel Sambuccharacter can be escaped by preceding it with a backslash.)
1461*84d9c625SLionel Sambuc@cindex buffer
1462*84d9c625SLionel Sambuc@IP{buffer}
1463*84d9c625SLionel Sambuc
1464*84d9c625SLionel SambucOne of a number of named areas for saving copies of text.
1465*84d9c625SLionel SambucCommands that change or delete text can save the changed or deleted
1466*84d9c625SLionel Sambuctext into a specific buffer, for later use, if the command allows
1467*84d9c625SLionel Sambucit (i.e.@: the
1468*84d9c625SLionel Sambuc@CO{ex}
1469*84d9c625SLionel Sambuc @CO{change}
1470*84d9c625SLionel Sambuc command cannot save the changed text in a named buffer).
1471*84d9c625SLionel SambucBuffers are named with a single character, preceded by a double quote,
1472*84d9c625SLionel Sambuce.g.
1473*84d9c625SLionel Sambuc@LI{}"<character>"
1474*84d9c625SLionel Sambucin
1475*84d9c625SLionel Sambuc@CO{vi}
1476*84d9c625SLionel Sambuc and
1477*84d9c625SLionel Sambucwithout the double quote, e.g.
1478*84d9c625SLionel Sambuc@LI{<character>},
1479*84d9c625SLionel Sambucin
1480*84d9c625SLionel Sambuc@CO{ex}  .
1481*84d9c625SLionel Sambuc(The double quote isn't necessary for
1482*84d9c625SLionel Sambuc@CO{ex}
1483*84d9c625SLionel Sambuc because buffers names are denoted by their position in the command line.)
1484*84d9c625SLionel SambucHistoric implementations of
1485*84d9c625SLionel Sambuc@EV{ex,vi}
1486*84d9c625SLionel Sambuclimited
1487*84d9c625SLionel Sambuc@LI{<character>}to the alphanumeric characters;
1488*84d9c625SLionel Sambuc@EV{nex,nvi}
1489*84d9c625SLionel Sambucpermits the use of any character without another meaning in the position
1490*84d9c625SLionel Sambucwhere a buffer name is expected.
1491*84d9c625SLionel Sambuc@sp 1
1492*84d9c625SLionel SambucBuffers named by uppercase characters are the same as buffers
1493*84d9c625SLionel Sambucnamed by lowercase characters, e.g. the buffer named by the
1494*84d9c625SLionel SambucEnglish character
1495*84d9c625SLionel Sambuc@QT{A}
1496*84d9c625SLionel Sambucis the same as the buffer named by the character
1497*84d9c625SLionel Sambuc@QT{a},
1498*84d9c625SLionel Sambucwith the exception that, if the buffer contents are being changed (as
1499*84d9c625SLionel Sambucwith a text deletion or
1500*84d9c625SLionel Sambuc@CO{vi}
1501*84d9c625SLionel Sambuc @CO{change}
1502*84d9c625SLionel Sambuc command), the text is
1503*84d9c625SLionel Sambuc@emph{appended}
1504*84d9c625SLionel Sambucto the buffer, instead of replacing the current contents.
1505*84d9c625SLionel Sambuc@sp 1
1506*84d9c625SLionel SambucThe buffers named by the numeric characters (in English,
1507*84d9c625SLionel Sambuc@QT{1}
1508*84d9c625SLionel Sambucthrough
1509*84d9c625SLionel Sambuc@QT{9}),
1510*84d9c625SLionel Sambucare special.
1511*84d9c625SLionel SambucIf a region of text including characters from more than one line,
1512*84d9c625SLionel Sambucor a single line of text specified by using a line-oriented motion,
1513*84d9c625SLionel Sambucis changed or deleted in the file using the
1514*84d9c625SLionel Sambuc@CO{vi}
1515*84d9c625SLionel Sambuc @CO{change}
1516*84d9c625SLionel Sambuc or
1517*84d9c625SLionel Sambuc@CO{delete}
1518*84d9c625SLionel Sambuc commands, a copy of the text is placed into the numeric buffer
1519*84d9c625SLionel Sambuc@QT{1},
1520*84d9c625SLionel Sambucregardless of the user specifying another buffer in which to save it.
1521*84d9c625SLionel SambucIn addition, there are a few commands which, when used as a
1522*84d9c625SLionel Sambuc@LI{motion}with the
1523*84d9c625SLionel Sambuc@CO{vi}
1524*84d9c625SLionel Sambuc @CO{change}
1525*84d9c625SLionel Sambuc and
1526*84d9c625SLionel Sambuc@CO{delete}
1527*84d9c625SLionel Sambuc commands,
1528*84d9c625SLionel Sambuc@emph{always}
1529*84d9c625SLionel Sambuccopy the specified region of text into the numeric buffers regardless
1530*84d9c625SLionel Sambucof the region including characters from more than one line.
1531*84d9c625SLionel SambucThese commands are:
1532*84d9c625SLionel Sambuc@sp 1
1533*84d9c625SLionel Sambuc@multitable {@CO{'<character>}} {@CO{AA}} {@CO{AA}} {@CO{AA}}
1534*84d9c625SLionel Sambuc@item @CO{<control-A>} @tab @CO{%} @tab @CO{(} @tab @CO{)}
1535*84d9c625SLionel Sambuc@item @CO{`<character>} @tab @CO{/} @tab @CO{?} @tab @CO{N}
1536*84d9c625SLionel Sambuc@item @CO{n} @tab @strong{@{} @tab @strong{@}}
1537*84d9c625SLionel Sambuc@end multitable
1538*84d9c625SLionel Sambuc@sp 1
1539*84d9c625SLionel SambucBefore this copy is done, the previous contents of buffer
1540*84d9c625SLionel Sambuc@QT{1}
1541*84d9c625SLionel Sambucare moved into buffer
1542*84d9c625SLionel Sambuc@QT{2},
1543*84d9c625SLionel Sambuc@QT{2}
1544*84d9c625SLionel Sambucinto buffer
1545*84d9c625SLionel Sambuc@QT{3},
1546*84d9c625SLionel Sambucand so on.
1547*84d9c625SLionel SambucThe contents of buffer
1548*84d9c625SLionel Sambuc@QT{9}
1549*84d9c625SLionel Sambucare discarded.
1550*84d9c625SLionel SambucIn
1551*84d9c625SLionel Sambuc@CO{vi}  ,
1552*84d9c625SLionel Sambuctext may be explicitly stored into the numeric buffers.
1553*84d9c625SLionel SambucIn this case, the buffer rotation described above occurs before the
1554*84d9c625SLionel Sambucreplacement of the buffer's contents.
1555*84d9c625SLionel SambucThe numeric buffers are only available in
1556*84d9c625SLionel Sambuc@LI{visual}and
1557*84d9c625SLionel Sambuc@LI{open}modes,
1558*84d9c625SLionel Sambucand are not accessible by
1559*84d9c625SLionel Sambuc@CO{ex}
1560*84d9c625SLionel Sambuc in any way, although changed and deleted text is still stored there
1561*84d9c625SLionel Sambucwhile in
1562*84d9c625SLionel Sambuc@CO{ex}
1563*84d9c625SLionel Sambuc mode.
1564*84d9c625SLionel Sambuc@sp 1
1565*84d9c625SLionel SambucWhen a
1566*84d9c625SLionel Sambuc@CO{vi}
1567*84d9c625SLionel Sambuc command synopsis shows both a
1568*84d9c625SLionel Sambuc@LI{[buffer]}and a
1569*84d9c625SLionel Sambuc@LI{[count]},
1570*84d9c625SLionel Sambucthey may be presented in any order.
1571*84d9c625SLionel Sambuc@sp 1
1572*84d9c625SLionel SambucFinally, all buffers are either
1573*84d9c625SLionel Sambuc@QQ{line}
1574*84d9c625SLionel Sambucor
1575*84d9c625SLionel Sambuc@QQ{character}
1576*84d9c625SLionel Sambucoriented.
1577*84d9c625SLionel SambucAll
1578*84d9c625SLionel Sambuc@CO{ex}
1579*84d9c625SLionel Sambuc commands which store text into buffers are line oriented.
1580*84d9c625SLionel SambucSome
1581*84d9c625SLionel Sambuc@CO{vi}
1582*84d9c625SLionel Sambuc commands which store text into buffers are line oriented,
1583*84d9c625SLionel Sambucand some are character oriented; the description for each applicable
1584*84d9c625SLionel Sambuc@CO{vi}
1585*84d9c625SLionel Sambuc command notes whether text copied into buffers using the command
1586*84d9c625SLionel Sambucis line or character oriented.
1587*84d9c625SLionel SambucIn addition, the
1588*84d9c625SLionel Sambuc@CO{vi}
1589*84d9c625SLionel Sambuc command
1590*84d9c625SLionel Sambuc@CO{display buffers}
1591*84d9c625SLionel Sambucdisplays the current orientation for each buffer.
1592*84d9c625SLionel SambucGenerally, the only importance attached to this orientation is that
1593*84d9c625SLionel Sambucif the buffer is subsequently inserted into the text, line oriented
1594*84d9c625SLionel Sambucbuffers create new lines for each of the lines they contain, and
1595*84d9c625SLionel Sambuccharacter oriented buffers create new lines for any lines
1596*84d9c625SLionel Sambuc@emph{other}
1597*84d9c625SLionel Sambucthan the first and last lines they contain.
1598*84d9c625SLionel SambucThe first and last lines are inserted into the text at the current
1599*84d9c625SLionel Sambuccursor position, becoming part of the current line.
1600*84d9c625SLionel SambucIf there is more than one line in the buffer, however, the current
1601*84d9c625SLionel Sambucline itself will be split.
1602*84d9c625SLionel Sambuc@cindex "unnamed buffer"
1603*84d9c625SLionel Sambuc@IP{unnamed buffer}
1604*84d9c625SLionel Sambuc
1605*84d9c625SLionel SambucThe unnamed buffer is a text storage area which is used by commands
1606*84d9c625SLionel Sambucthat use or operate on a buffer when no buffer is specified by the user.
1607*84d9c625SLionel SambucIf the command stores text into a buffer,
1608*84d9c625SLionel Sambucthe text is stored into the unnamed buffer even if a buffer is also
1609*84d9c625SLionel Sambucspecified by the user.
1610*84d9c625SLionel SambucIt is not possible to append text to the unnamed buffer.
1611*84d9c625SLionel SambucIf text is appended to a named buffer,
1612*84d9c625SLionel Sambucthe named buffer contains both the old and new text,
1613*84d9c625SLionel Sambucwhile the unnamed buffer contains only the new text.
1614*84d9c625SLionel SambucThere is no way to explicitly reference the unnamed buffer.
1615*84d9c625SLionel Sambuc@sp 1
1616*84d9c625SLionel SambucHistorically, the contents of the unnamed buffer were discarded by many
1617*84d9c625SLionel Sambucdifferent commands, even ones that didn't store text into it.
1618*84d9c625SLionel Sambuc@EV{Nex,nvi}
1619*84d9c625SLionel Sambucnever discards the contents of the unnamed buffer until new text
1620*84d9c625SLionel Sambucreplaces them.
1621*84d9c625SLionel Sambuc@cindex whitespace
1622*84d9c625SLionel Sambuc@IP{whitespace}
1623*84d9c625SLionel Sambuc
1624*84d9c625SLionel SambucThe characters <tab> and <space>.
1625*84d9c625SLionel Sambuc@cindex "<carriage-return>"
1626*84d9c625SLionel Sambuc@IP{<carriage-return>}
1627*84d9c625SLionel Sambuc
1628*84d9c625SLionel SambucThe character represented by an ASCII
1629*84d9c625SLionel Sambuc@LI{<control-M>}.
1630*84d9c625SLionel SambucThis character is almost always treated identically to a
1631*84d9c625SLionel Sambuc@LI{<newline>}character, but differs in that it can be escaped into the file text or
1632*84d9c625SLionel Sambucinto a command.
1633*84d9c625SLionel Sambuc@cindex <newline>
1634*84d9c625SLionel Sambuc@IP{<newline>}
1635*84d9c625SLionel Sambuc
1636*84d9c625SLionel SambucThe character represented by an ASCII
1637*84d9c625SLionel Sambuc@LI{<control-J>}.
1638*84d9c625SLionel SambucThis character is almost always treated identically to a
1639*84d9c625SLionel Sambuc@LI{<control-M>}character, but differs in that it cannot be escaped into the file text or
1640*84d9c625SLionel Sambucinto a command.
1641*84d9c625SLionel Sambuc@end itemize
1642*84d9c625SLionel Sambuc@comment .oh 'Vi/Ex Reference (Vi Commands)''USD:13-%'
1643*84d9c625SLionel Sambuc@comment .eh 'USD:13-%''Vi/Ex Reference (Vi Commands)'
1644*84d9c625SLionel Sambuc@node Vi Commands,(dir),(dir),(dir)
1645*84d9c625SLionel Sambuc@include vi.cmd.texi
1646*84d9c625SLionel Sambuc@comment .oh 'Vi/Ex Reference''USD:13-%'
1647*84d9c625SLionel Sambuc@comment .eh 'USD:13-%''Vi/Ex Reference'
1648*84d9c625SLionel Sambuc@chapter Ex Addressing
1649*84d9c625SLionel Sambuc
1650*84d9c625SLionel SambucAddressing in
1651*84d9c625SLionel Sambuc@CO{ex}
1652*84d9c625SLionel Sambuc (and when
1653*84d9c625SLionel Sambuc@CO{ex}
1654*84d9c625SLionel Sambuc commands are executed from
1655*84d9c625SLionel Sambuc@CO{vi}  )
1656*84d9c625SLionel Sambucrelates to the current line.
1657*84d9c625SLionel SambucIn general, the current line is the last line affected by a command.
1658*84d9c625SLionel SambucThe exact effect on the current line is discussed under the description
1659*84d9c625SLionel Sambucof each command.
1660*84d9c625SLionel SambucWhen the file contains no lines, the current line is zero.
1661*84d9c625SLionel Sambuc
1662*84d9c625SLionel SambucAddresses are constructed by one or more of the following methods:
1663*84d9c625SLionel Sambuc@enumerate
1664*84d9c625SLionel Sambuc@item
1665*84d9c625SLionel SambucThe address
1666*84d9c625SLionel Sambuc@QT{.}
1667*84d9c625SLionel Sambucrefers to the current line.
1668*84d9c625SLionel Sambuc@item
1669*84d9c625SLionel SambucThe address
1670*84d9c625SLionel Sambuc@QT{$}
1671*84d9c625SLionel Sambucrefers to the last line of the file.
1672*84d9c625SLionel Sambuc@item
1673*84d9c625SLionel SambucThe address
1674*84d9c625SLionel Sambuc@QT{N},
1675*84d9c625SLionel Sambucwhere
1676*84d9c625SLionel Sambuc@LI{N}is a positive number, refers to the N-th line of the file.
1677*84d9c625SLionel Sambuc@item
1678*84d9c625SLionel SambucThe address
1679*84d9c625SLionel Sambuc@QT{'<character>}
1680*84d9c625SLionel Sambucor
1681*84d9c625SLionel Sambuc@QT{`<character>}
1682*84d9c625SLionel Sambucrefers to the line marked with the name
1683*84d9c625SLionel Sambuc@LI{<character>}.
1684*84d9c625SLionel Sambuc(See the
1685*84d9c625SLionel Sambuc@CO{k}
1686*84d9c625SLionel Sambuc or
1687*84d9c625SLionel Sambuc@CO{m}
1688*84d9c625SLionel Sambuc commands for more information on how to mark lines.)
1689*84d9c625SLionel Sambuc@item
1690*84d9c625SLionel SambucA regular expression (RE) enclosed by slashes
1691*84d9c625SLionel Sambuc@PQ{/}
1692*84d9c625SLionel Sambucis an address,
1693*84d9c625SLionel Sambucand it refers to the first line found by searching forward from the line
1694*84d9c625SLionel Sambuc@emph{after}
1695*84d9c625SLionel Sambucthe current line toward the end of the file, and stopping at the
1696*84d9c625SLionel Sambucfirst line containing a string matching the RE.
1697*84d9c625SLionel Sambuc(The trailing slash can be omitted at the end of the command line.)
1698*84d9c625SLionel Sambuc@sp 1
1699*84d9c625SLionel SambucIf no RE is specified, i.e.@: the pattern is
1700*84d9c625SLionel Sambuc@QT{//},
1701*84d9c625SLionel Sambucthe last RE used in any command is used in the search.
1702*84d9c625SLionel Sambuc@sp 1
1703*84d9c625SLionel SambucIf the
1704*84d9c625SLionel Sambuc@OP{extended}
1705*84d9c625SLionel Sambucoption is set, the RE is handled as an extended RE, not a basic RE.
1706*84d9c625SLionel SambucIf the
1707*84d9c625SLionel Sambuc@OP{wrapscan}
1708*84d9c625SLionel Sambucoption is set, the search wraps around to the beginning of the file
1709*84d9c625SLionel Sambucand continues up to and including the current line, so that the entire
1710*84d9c625SLionel Sambucfile is searched.
1711*84d9c625SLionel Sambuc@sp 1
1712*84d9c625SLionel SambucThe form
1713*84d9c625SLionel Sambuc@QT{\e/}
1714*84d9c625SLionel Sambucis accepted for historic reasons,
1715*84d9c625SLionel Sambucand is identical to
1716*84d9c625SLionel Sambuc@QT{//}.
1717*84d9c625SLionel Sambuc@item
1718*84d9c625SLionel SambucAn RE enclosed in question marks
1719*84d9c625SLionel Sambuc@PQ{?}
1720*84d9c625SLionel Sambucaddresses the first line found by searching backward from the line
1721*84d9c625SLionel Sambuc@emph{preceding}
1722*84d9c625SLionel Sambucthe current line, toward the beginning of the file and stopping at the
1723*84d9c625SLionel Sambucfirst line containing a string matching the RE.
1724*84d9c625SLionel Sambuc(The trailing question mark can be omitted at the end of a command line.)
1725*84d9c625SLionel Sambuc@sp 1
1726*84d9c625SLionel SambucIf no RE is specified, i.e.@: the pattern is
1727*84d9c625SLionel Sambuc@QT{??},
1728*84d9c625SLionel Sambucthe last RE used in any command is used in the search.
1729*84d9c625SLionel Sambuc@sp 1
1730*84d9c625SLionel SambucIf the
1731*84d9c625SLionel Sambuc@OP{extended}
1732*84d9c625SLionel Sambucoption is set, the RE is handled as an extended RE, not a basic RE.
1733*84d9c625SLionel SambucIf the
1734*84d9c625SLionel Sambuc@OP{wrapscan}
1735*84d9c625SLionel Sambucoption is set, the search  wraps around from the beginning of the file to
1736*84d9c625SLionel Sambucthe end of the file and continues up to and including the current line,
1737*84d9c625SLionel Sambucso that the entire file is searched.
1738*84d9c625SLionel Sambuc@sp 1
1739*84d9c625SLionel SambucThe form
1740*84d9c625SLionel Sambuc@QT{\e?}
1741*84d9c625SLionel Sambucis accepted for historic reasons, and is identical to
1742*84d9c625SLionel Sambuc@QT{??}.
1743*84d9c625SLionel Sambuc@item
1744*84d9c625SLionel SambucAn address followed by a plus sign
1745*84d9c625SLionel Sambuc@PQ{+}
1746*84d9c625SLionel Sambucor a minus sign
1747*84d9c625SLionel Sambuc@PQ{-}
1748*84d9c625SLionel Sambucfollowed by a number is an offset address and refers to the address
1749*84d9c625SLionel Sambucplus (or minus) the indicated number of lines.
1750*84d9c625SLionel SambucIf the address is omitted, the addition or subtraction is done with
1751*84d9c625SLionel Sambucrespect to the current line.
1752*84d9c625SLionel Sambuc@item
1753*84d9c625SLionel SambucAn address of
1754*84d9c625SLionel Sambuc@QT{+}
1755*84d9c625SLionel Sambucor
1756*84d9c625SLionel Sambuc@QT{-}
1757*84d9c625SLionel Sambucfollowed by a number is an offset from the current line.
1758*84d9c625SLionel SambucFor example,
1759*84d9c625SLionel Sambuc@QT{-5}
1760*84d9c625SLionel Sambucis the same as
1761*84d9c625SLionel Sambuc@QT{.-5}.
1762*84d9c625SLionel Sambuc@item
1763*84d9c625SLionel SambucAn address ending with
1764*84d9c625SLionel Sambuc@QT{+}
1765*84d9c625SLionel Sambucor
1766*84d9c625SLionel Sambuc@QT{-}
1767*84d9c625SLionel Sambuchas 1 added to or subtracted from the address, respectively.
1768*84d9c625SLionel SambucAs a consequence of this rule and of the previous rule, the address
1769*84d9c625SLionel Sambuc@QT{-}
1770*84d9c625SLionel Sambucrefers to the line preceding the current line.
1771*84d9c625SLionel SambucMoreover, trailing
1772*84d9c625SLionel Sambuc@QT{+}
1773*84d9c625SLionel Sambucand
1774*84d9c625SLionel Sambuc@QT{-}
1775*84d9c625SLionel Sambuccharacters have a cumulative effect.
1776*84d9c625SLionel SambucFor example,
1777*84d9c625SLionel Sambuc@QT{++-++}
1778*84d9c625SLionel Sambucrefers to the current line plus 3.
1779*84d9c625SLionel Sambuc@item
1780*84d9c625SLionel SambucA percent sign
1781*84d9c625SLionel Sambuc@PQ{%}
1782*84d9c625SLionel Sambucis equivalent to the address range
1783*84d9c625SLionel Sambuc@QT{1,$}.
1784*84d9c625SLionel Sambuc@end enumerate
1785*84d9c625SLionel Sambuc
1786*84d9c625SLionel Sambuc@CO{Ex}
1787*84d9c625SLionel Sambuc commands require zero, one, or two addresses.
1788*84d9c625SLionel SambucIt is an error to specify an address to a command which requires zero
1789*84d9c625SLionel Sambucaddresses.
1790*84d9c625SLionel Sambuc
1791*84d9c625SLionel SambucIf the user provides more than the expected number of addresses to any
1792*84d9c625SLionel Sambuc@CO{ex}
1793*84d9c625SLionel Sambuc command, the first addresses specified are discarded.
1794*84d9c625SLionel SambucFor example,
1795*84d9c625SLionel Sambuc@QT{1,2,3,5}print
1796*84d9c625SLionel Sambucprints lines 3 through 5, because the
1797*84d9c625SLionel Sambuc@CO{print}
1798*84d9c625SLionel Sambuc command only takes two addresses.
1799*84d9c625SLionel Sambuc
1800*84d9c625SLionel SambucThe addresses in a range are separated from each other by a comma
1801*84d9c625SLionel Sambuc@PQ{,}
1802*84d9c625SLionel Sambucor a semicolon
1803*84d9c625SLionel Sambuc@PQ{;}.
1804*84d9c625SLionel SambucIn the latter case, the current line
1805*84d9c625SLionel Sambuc@PQ{.}
1806*84d9c625SLionel Sambucis set to the first address, and only then is the second address calculated.
1807*84d9c625SLionel SambucThis feature can be used to determine the starting line for forward and
1808*84d9c625SLionel Sambucbackward searches (see rules (5) and (6) above).
1809*84d9c625SLionel SambucThe second address of any two-address sequence corresponds to a line that
1810*84d9c625SLionel Sambucfollows, in the file, the line corresponding to the first address.
1811*84d9c625SLionel SambucThe first address must be less than or equal to the second address.
1812*84d9c625SLionel SambucThe first address must be greater than or equal to the first line of the
1813*84d9c625SLionel Sambucfile, and the last address must be less than or equal to the last line
1814*84d9c625SLionel Sambucof the file.
1815*84d9c625SLionel Sambuc@comment .oh 'Vi/Ex Reference (Ex Commands)''USD:13-%'
1816*84d9c625SLionel Sambuc@comment .eh 'USD:13-%''Vi/Ex Reference (Ex Commands)'
1817*84d9c625SLionel Sambuc@node Ex Commands,(dir),(dir),(dir)
1818*84d9c625SLionel Sambuc@include ex.cmd.texi
1819*84d9c625SLionel Sambuc@comment .oh 'Vi/Ex Reference (Options)''USD:13-%'
1820*84d9c625SLionel Sambuc@comment .eh 'USD:13-%''Vi/Ex Reference (Options)'
1821*84d9c625SLionel Sambuc@include set.opt.texi
1822*84d9c625SLionel Sambuc@comment .oh 'Vi/Ex Reference''USD:13-%'
1823*84d9c625SLionel Sambuc@comment .eh 'USD:13-%''Vi/Ex Reference'
1824*84d9c625SLionel Sambuc@page
1825*84d9c625SLionel Sambuc@chapter Index
1826*84d9c625SLionel Sambuc@printindex cp
1827*84d9c625SLionel Sambuc@comment  Force the TOC to an odd page, in case it's a duplex printer.
1828*84d9c625SLionel Sambuc@bye
1829