MAINEDIT User's Guide, Chapter 8

previous   next   top   contents   index   framed top   this page unframed


8. Other Text Modifying Commands

8.1. Center

The .C (Center) command centers the visible part of the current line of text within the current line. That is, the amount of white space between the left margin and the leftmost visible character on the line is made to be (to the best approximation possible) the same as the amount of white space between the right margin and the rightmost visible character on the line. See Table 8–1.

Table 8–1. Commands to Center Text on a Line
Command Center:
n.C n lines (but not beyond end of window)
Q.C all lines to end of window or page

8.2. Copy

The C (Copy) command duplicates characters, words, lines, or pages. See Table 8–2.

Table 8–2. Commands to Copy Text
Command Copy:
nC[C|W|L|P] n objects at and after
QC[C|W|L|P] all objects at and after
-nC[C|W|L|P] n objects before
-QC[C|W|L|P] all objects before

For example, suppose the cursor is under the word “orange” in the following sentence:

The bright orange balloon rose into the sky.
              ^

Typing CW (Copy Word) copies the word orange and positions the cursor at the beginning of the second occurrence of the copied object:

The bright orange orange balloon rose into the sky.
                  ^

The count modifier specifies the number of objects to be copied, not the number of times an object is to be copied. Using the same sample sentence, the 2CW command copies “orange balloon”:

The bright orange balloon orange balloon rose into the sky.
                          ^

To copy the objects before the current object, modify the copy command with -. Again using the “orange balloon” sentence as an example, the -CW command copies the word bright and positions the cursor at the beginning of the first occurrence of the copied object:

The bright bright orange balloon rose into the sky.
    ^

8.3. Move

The M (Move) command rearranges text by changing the order of characters, words, lines, or pages. See Table 8–3. The M commands without count or emphasis can be thought of as “swaps”; e.g., MW swaps the next two words.

Table 8–3. Text Rearranging Commands
Command Move current object:
nM[C|W|L|P] n further
QM[C|W|L|P] to end (of line, line, window, or buffer, respectively)
-nM[C|W|L|P] n earlier
-QM[C|W|L|P] to start (of line, line, window, or buffer, respectively)

For example, suppose the cursor is positioned at the n in the word orange in the following sentence:

The bright orange balloon caught their attention.
              ^

The MW (Move Word) command moves the word orange one word to the right, positioning the cursor at the beginning of the object beyond the one moved:

The bright balloon orange caught their attention.
           ^

Typing MC (Move Character) moves the character at the cursor one position to the right, and positions the cursor at the character beyond the one moved:

The bright oragne balloon caught their attention.
              ^

The - modifier changes the direction of the move to be towards the left, or towards the beginning of the buffer. -MW applied to the original sentence results in:

The orange bright balloon caught their attention.
           ^

-M forms leave the cursor at the beginning of the object that was originally located immediately before the moved object.

8.4. Break

The B (Break) command breaks a line at the current cursor position into two lines. Modifiers are used to specify where to position the first visible character on the second line, and where to leave the cursor. See Table 8–4.

When a count n is specified, the first visible character on the second line is positioned to column n + 1. The “spaces” added by the nB forms are actually tab characters. They may be replaced with spaces when the file is written out in accordance with the rules in Section 1.11 of the MAINEDIT User's Guide.

When the - modifier is specified, the cursor is positioned after the last character on the first line. Otherwise, it is positioned on the first visible character of the second line.

Table 8–4. Commands to Break a Line
Command Break line at cursor, then:
B remove spaces, cursor to second line
nB indent n spaces, cursor to second line
QB leave original spaces, cursor to second line
-B remove spaces, cursor to end of first line
-nB indent n spaces, cursor to end of first line
-QB leave original spaces, cursor to end of 1st line

8.5. Join

The J (Join) command joins two lines. Modifiers are used to specify which lines are joined, and how many spaces are to separate the two joined pieces of the new line. See Table 8–5.

The spaces inserted by the nJ forms are space characters, not tab characters.

Table 8–5. Commands to Join Two Lines
Command Join:
nJ next to current line, n separating spaces
QJ next to current line, leave original spaces
-nJ current to previous line, n separating spaces
-QJ current to previous line, leave original spaces

8.6. Convert to Lower or Upper Case

The L (Lower case) and U (Upper case) commands convert alphabetic text to lower or upper case, respectively. They have no effect on non-alphabetic characters. See Table 8–6. These commands position the cursor at the beginning of the object beyond the last one converted.

Table 8–6. Commands to Convert to Lower/Upper Case
Command Convert:
nL[C|W|L] n objects to lower case
QL[C|W|L] all objects to lower case
nU[C|W|L] n objects to upper case
QU[C|W|L] all objects to upper case

8.7. Filling and Justification

The filling and justification (.J) commands are shown in Table 8–7. They provide a way to fill paragraphs and optionally justify the right margin. Filling a paragraph eliminates excess blank space within and at the end of lines; justifying aligns a margin, so that the entire column at the margin contains printing characters.

Table 8–7. Commands to Fill and Justify Text
Command Effect
.J Fill current paragraph to right margin of window
$.J Fill and preserve spaces after punctuation
n.J Fill n lines
+.J Fill and justify to right margin of window
-.J Fill starting at cursor column
Q.J Fill all remaining paragraphs in buffer
.mJ Fill to right margin in column m
nQ.J Fill next n paragraphs
(All modifiers may be combined; i.e., nQ+-.m.J means fill next n paragraphs from cursor column, justifying to column m).

The .J command with no modifiers fills the current paragraph. The current paragraph starts with the first non-blank line at or beyond the current line. It extends either to the first line that does not contain a visible character in the first column or to a page mark, whichever comes first. With this form of the command, it does not matter where the cursor is on the line. Multiple spaces in a filled paragraph are changed to a single space.

If a count (n) is specified, then only the first n lines of the paragraph are filled. If n is larger than the number of lines in the current paragraph, only the current paragraph is filled.

If n is not specified, the emphasis modifier (Q) means fill all remaining paragraphs in the buffer; if n is specified, it means fill the next n paragraphs.

The plus modifier (+) means fill with an even right margin (“justify”). Spaces are scattered in the filled text to make the right margin of all but (possibly) the last line even.

The .m modifier means fill with the right margin set to m (the displayed right margin of the window remains unchanged). If .m is not specified, the right margin of the window is used.

The minus modifier (-) means fill between the current column and the right margin only. This form of the command is useful when filling indented text. When using this form of the fill command, make sure that the cursor is positioned in the column at which filling is to begin; all characters to the left of this column are ignored and remain unaltered. Filling extends until MAINED encounters a line without a printing character in the current column. If, after filling, new line(s) are created, the text to the left of the current column on the existing filled lines is examined. If this text is identical on all filled lines, then that text is inserted to the left of the current column on every new line added as a result of the fill. Otherwise, blanks are added to the left of the current column on new line(s). This seems to give desirable results in most cases.

The dollar sign modifier ($) means to retain extra spaces after punctuation, if the spaces appeared in the paragraph before filling. The rule used is:

Some examples of the .J command are shown in Examples 8–8, 8–9, and 8–10.

Example 8–8. .J Command, Example 1
A window that originally looks like this:

:                                        :
:
The ".mmodifier means fill with the ri*
 ^
:
actual right margin remains unchanged). *
:
current right margin is used.           :
:                                        :

looks like this after .J:

:                                        :
:
The ".mmodifier means fill with the   :
:
right margin set to m (the actual right :
:
margin remains unchanged). If ".mis   :
:
not specifiedthe current right margin :
:
is used.                                :
:                                        :

and looks like this after +.J:

:                                        :
:
The ".m"  modifier  means fill  with the:
:
right  margin set to m (the actual right:
:
margin remains  unchanged).  If  ".mis:
:
not specifiedthe current right  margin:
:
is used.                                :
:                                        :

The position of the cursor on the first line does not matter; i.e., it can be positioned anywhere on the first line.

Example 8–9. .J Command, Example 2
A window that originally looks like this:

:                                        :
:
trunc(x)    x is a real valuethe resul*
             ^
:            (
The fractional part is disc*
:            
trunc(3.7) = 3 and trunc(-3.*
:                                        :
:
round(x)    x is a real valuethe resul*
             ^
:            
integerround(xmeans for *
:            
for x < 0 trunc(x - 0.5)    *
:                                        :

looks like this after moving the cursor to each position indicated by ^ and typing -.J:

:                                        :
:
trunc(x)    x is a real valuethe      :
:            
result is its whole part.   :
:            (
The fractional part is     :
:            
discardedHence trunc(3.7) :
:            = 3 
and trunc(-3.7) = -3)   :
:                                        :
:                                        :
:
round(x)    x is a real valuethe      :
:            
result is the rounded       :
:            
integerround(xmeans for :
:            
x >= 0 trunc(x + 0.5), and  :
:            
for x < 0 trunc(x - 0.5)    :
:                                        :

The cursor must be positioned as shown.

Example 8–10. .J Command, Example 3
A window that originally looks like this:

:                                        :
:# 
Window bp got bigger (it may have just*
   ^
:# 
are pushed down (possibly disappearing*
:# 
ctrlBit is setotherwise they are ove*
:# 
pushed up (possibly disappearingif t*
:# 
setotherwise they are overlayed.    *
:                                        :

looks like this after -.J:

:                                        :
:# 
Window bp got bigger (it may have just:
:# 
been created). Lower windows are      :
:# 
pushed down (possibly disappearingif:
:# 
the pushWindowsBelow ctrlBit is set;  :
:# 
otherwise they are overlayedHigher  :
:# 
windows are pushed up (possibly       :
:# 
disappearingif the pushWindowsAbove :
:# 
ctrlBit is setotherwise they are    :
:# 
overlayed.                            :
:                                        :

and looks like this after +-.J:

:                                        :
:# 
Window bp got bigger (it may have just:
:# 
been   created).   Lower  windows  are:
:# 
pushed down (possibly disappearingif:
:# 
the pushWindowsBelow ctrlBit  is  set;:
:# 
otherwise  they  are overlayedHigher:
:# 
windows   are  pushed   up   (possibly:
:# 
disappearingif  the pushWindowsAbove:
:# 
ctrlBit  is set;  otherwise  they  are:
:# 
overlayed.                            :
:                                        :

The newly created lines start with a pound sign and a blank, since that text started all of the original lines. The cursor must be positioned as shown.


previous   next   top   contents   index   framed top   this page unframed

MAINEDIT User's Guide, Chapter 8