previous next top contents index framed top this page unframed
MAINED provides a complete set of commands to manipulate files and buffers; you may want to use some of these commands from other front ends as well as from MAINED, since some of the front ends are based on editors that do not have as flexible a notion of file and buffer as MAINED, and therefore do not have all the commands that MAINED does.
10.1. Bringing a File into the Editor
The .F (File) command moves
the cursor into a buffer associated with
the file of the specified name.
If a buffer associated with the file
does not exist, it is created.
When any of the commands in Table 10–1 is issued, MAINEDIT prompts for the file name s on the message line at the top of the screen. The subsequent dialogue is the same as that described for the initial file in Chapter 1 of the MAINEDIT User's Guide, except that if you type the name of a file for which a buffer already exists, MAINEDIT prompts to confirm that you want to use the existing buffer. The .B command is usually used to move into an existing buffer; the .F command is intended primarily for creating new buffers.
Table 10–1. File Selection Commands
| Command | Action |
|---|---|
| .Fs | edit file s; use current window if not on screen |
| n.Fs | same as .Fs, except n-row window (n required) |
| +.Fs | edit file s; insert new window at bottom if not on screen |
| +n.Fs | same as +.Fs, except n-row window (n required) |
| -.Fs | edit file s; insert new window at top if not on screen |
| -n.Fs | same as -.Fs, except n-row window (n required) |
| --{n}.Fs | overlay (n-row) window at top |
| ++{n}.Fs | overlay (n-row) window at bottom |
| ..{n}Fs | edit s, making window 1/mth of screen, where m is the number of windows; but no window is allowed to be smaller than n lines |
| +..{n}Fs | do a +{n}.F, then make all windows same size |
| -..{n}Fs | do a -{n}.F, then make all windows same size |
| Q.Fs | change file name of current buffer to s |
| .F?<eol> | display names of most recently edited files |
When any of the commands in Table 10–2 is issued, MAINEDIT prompts for the buffer name s on the message line at the top of the screen. If the buffer exists, MAINEDIT positions the cursor there; if not, MAINEDIT inquires whether you wish to create a new buffer.
Table 10–2. Buffer Selection Commands
| Command | Action |
|---|---|
| .Bs | edit buffer s; use current window if not on screen |
| n.Bs | same as .Bs, except n-row window (n required) |
| +.Bs | edit buffer s; insert new window at bottom if not on screen |
| +n.Bs | same as +.Bs, except n-row window (n required) |
| -.Bs | edit file s; insert new window at top if not on screen |
| -n.Bs | same as -.Bs, except n-row window (n required) |
| --{n}.Bs | overlay (n-row) window at top |
| ++{n}.Bs | overlay (n-row) window at bottom |
| ..{n}Bs | edit s, making window 1/mth of screen, where m is the number of windows; but no window is allowed to be smaller than n lines |
| +..{n}Bs | do a +{n}.B, then make all windows same size |
| -..{n}Bs | do a -{n}.B, then make all windows same size |
| Q.Bs | change buffer name of current buffer to s |
| .B?<eol> | display names of most recently edited buffers |
If the buffer you want to edit is already visible in a window on the
screen, the cursor is moved to that window and is positioned at
the last place you edited in that buffer.
The minus minus modifier (--)
means overlay the window at the top if
it is not already on the screen.
If n is specified, the new window is n
rows; otherwise it occupies the top half the screen.
The plus plus modifier (++) means
overlay the window at the bottom if
it is not already on the screen. If n is specified,
the new window is n
rows; otherwise it occupies the bottom half of the screen.
The dot dot modifier (..) means make all windows on the screen the
same size (proportional windows). A new window is created if it is not
already on the screen. If there are m
windows on the screen, then the
size of each window is adjusted so
that the window occupies 1/mth of the
screen.
n is the minimum number of rows
(excluding the status line) in a
window (1 if n is unspecified).
n is sticky, i.e., it remains in effect
until changed by a subsequent
..{n}B or ..{n}F command. When a new
window is created, some existing windows may be killed to ensure that
all remaining windows are at least n rows.
The ..{n}B and ..{n}F
commands do not affect the setting
of the proportionalWindowsMode option
discussed in Chapter 16.
The plus dot dot (+..) or
minus dot dot (-..) modifier combines
the effect of the plus or minus modifier and the dot dot modifier.
These are often the most useful modifiers, since by default
(with no size argument) they add a new window
to the screen and resize the other windows to accommodate it.
For example, if you are editing three windows, and want to edit a
file foo in a fourth window at the top of the screen,
and also to adjust each window to
occupy a quarter of the screen, you would issue the command:
When the .B commands prompt for the buffer name, they offer
as a default
the name of the buffer in which the cursor was located before
it was moved to the current buffer, if any.
For example:
The default makes it simple to bounce back and forth between two
buffers.
The .B command accepts a string that is a substring of an existing
buffer name, e.g., OUT or LINE
would be sufficient to specify the buffer OUTLINE.
If you give an answer that is a substring of more than one
existing buffer name, one of the buffers is arbitrarily chosen by
MAINEDIT.
If the name you specify is not a substring of an existing
buffer, MAINEDIT asks:
Type Y (or y) to create a new buffer.
If you do so, a buffer containing
a single blank line is created and the cursor moved to
its window.
If you type N (or n) to the New buffer prompt,
the original Buffer: prompt is repeated.
You may wish to use the <abort> key to discontinue the dialogue
if you decide you do not want to change buffers after all; see
Section 13.1.
The .Y command (see Chapter 3) provides a
simple means of moving among buffers that are visible on the
screen.
If you
specify ? as the name of a file to edit,
either as part of MAINEDIT's
.F command or in response to MAINEDIT's initial file prompt,
MAINEDIT
displays in CMDLOG the names of the files you've recently
edited, one per line, most recently edited first, and place the cursor
at the start of the first line it displays.
You can use this feature if you want to edit a file that you have
recently edited (i.e., it is still in the editor's context), but it
is not the most recently edited file, and you do not want to retype
its name. Once the editor displays the names of the files in its
context, you can edit any file in the list without actually
having to type its name by moving the cursor to the line containing the
file to be edited, typing .DL
(to save the file name in the editor's
line delete buffer), typing .F
(or whatever command you want to use to edit
a file), and responding to the editor's File:
prompt with <ecm> (to
recover the file name from the line delete buffer).
Similarly, if you specify ? as the buffer name as part of MAINEDIT's
.B command,
MAINEDIT displays the names of its buffers in CMDLOG,
one per line, most recently edited first, and places the cursor at the
start of the first line it displays.
10.3. Modifiers of the .F and .B Commands
The plus modifier (+) means insert
the window at the bottom if it is
not already on the screen (all windows
above are pushed up). If n is
specified the new window is n rows;
otherwise it occupies the bottom
half of the screen.
-..Ffoo<eol>
Buffer (MEMO): <eol> (to go to buffer MEMO)
Buffer (MEMO): OUTLINE<eol> (to go to buffer OUTLINE)
New buffer OUTLINE (Yes No)?
10.4. Deleting Buffers
You are encouraged to delete a buffer if you are finished with it,
since this frees the memory space used by the buffer. The .K
(Kill buffers) command causes MAINED to prompt for each buffer asking
whether you want to kill it. Each prompt is as follows:
Kill buffer MEMO (Yes No)?
Type Y (or y) to delete the buffer, N (or n) to retain it. If you delete a buffer that has been changed since it was last saved, MAINEDIT prompts:
Write buffer MEMO (Yes No)?
Type Y (or y) to save the text in this buffer on a file (if you do not do so, your changes to the buffer are lost). When a buffer in a window on the screen is deleted, it disappears from the screen. If the current buffer is killed, MAINEDIT prompts for a new buffer to which to move the cursor (unless all the buffers have been killed, in which case it prompts for a file to edit).
The form Q.K is used to kill just one buffer. This command
prompts for the name of the buffer to kill, the default being
the current buffer.
10.5. Changing Buffer and File Names
Buffer and file names are changed with the Q.Bs and Q.Fs
commands. See Table 10–3.
Table 10–3. Commands to Change Buffer and File Names
| Command | Action |
|---|---|
| Q.Bs<eol> | Change buffer name of current buffer to s |
| Q.B<eol> | Change buffer name to current file name in upper case |
| Q.Fs<eol> | Change file name of current buffer to s |
MAINED prompts for s on the message line. For Q.B, MAINED offers the file name associated with the current buffer, converted to upper case, as the default buffer name. Type the new buffer name, or just <eol> to accept the default:
New buffer name (BAR): FOO<eol>
(to change the current buffer's name to FOO)
New buffer name (BAR): <eol>
(to change the current buffer's name to BAR)
The file name associated with a buffer
is the default name of the file into which the text of the buffer
is copied when the buffer is saved.
The file name associated with a buffer is
independent of the buffer name, but by default the buffer name is
the same as its associated file name converted to upper case.
10.6. Displaying Information about Buffers and Files
The Q= command displays a list of the current buffers and their
status. The list is displayed in a buffer named CMDLOG
(ComManD LOG).
If CMDLOG does not exist or is invisible, it is created or brought
into view as described in Chapter 17.
Example 10–4 shows the format of the information displayed by the Q= command. The buffer name of each edit buffer is displayed in the BUFFER column. The FILE column shows the name of the file associated with the buffer, if any. The STATUS may contain three different characters:
Example 10–4. Sample Output from the Q= Command
| STATUS BUFFER FILE ------ ------ ---- D CMDLOG D A EDTMGR.MSS edtmgr.mss S FOO foo D A EDTMGR-UPGRADE.TXT edtmgr-upgrade.txt EDIT.MSL edit.msl MAINED.MSL mained.msl |
When the .B and .F commands are typed, the user is prompted for a buffer or file name, respectively. If the specified name is followed by a comma, then MAINEDIT prompts for the names of the front and back ends to be used for the buffer. Defaults are offered in parentheses. The currently supported back ends are DATMGR and TXTMGR.
In addition to the standard back ends, MAINEDIT recognizes the special form =foo. In this case, MAINEDIT assumes that foo is the name of a buffer (partial matches are recognized) and it shares that buffer's back end as the back end of the new buffer. This means that the new buffer shares the same data as the buffer FOO. The response =<eol> is equivalent to =foo<eol> if foo is the current buffer.
When changes are made to data shared by more than one buffer, the changes are reflected in all buffers that share the data (there is only one copy of the data). In addition, all windows in which the affected data are visible are updated. There is no limit on the number of buffers that can share the same back end.
To create a new buffer FOO2 that shares the same data as an existing buffer FOO, do:
-.B Create a new buffer (at top of screen)
foo2,<eol> Call it foo2, enter subcommand mode
Y Yes to New buffer prompt
<eol> Use default front end
=foo<eol> Use foo's back end for foo2
During MAINEDIT's initial dialogue, the user is prompted for the name of a file to edit. If the last character of the response is a comma, then MAINEDIT strips off the comma and prompts for the display module. When MAINEDIT creates the initial buffer, it once again examines the last of the remaining characters. If it is a comma, MAINEDIT strips it off and prompts for the names of the front and back ends to be used for the buffer. Thus, to specify a front or back end different from the default for the initial buffer, type two commas after the file name.