Topic: Macro for Formatting Text Paragraphs (1 of 1), Read 100 times
Conf: Keyboard, keystroke macros
From: Deleted User
Date: Thursday, March 25, 1999 11:52 AM

Here is a keyboard macro that I wrote to format paragraphs with the
left margin at the far left and with the first line indented using three
spaces. This is the standard format that I use when writing text (such
as for this message).

The macro overcomes a bug in Vedit as of version 5.14.2 that causes
it to refuse to leave short lines indented when the paragraph is
reformatted. When the second line of a paragraph starts with leading
spaces, some of the three spaces inserted will be lost. That's why the
macro goes back a third time to check. If the second line starts out
with more than three spaces, then this macro will still not correct the
problem (creation of a hanging paragraph).

To use this as a keyboard macro, the version at the end (combined
into a single line) should be used.


[VISUAL EXIT] // enter command mode
CF(W_WORD_WRAP,1) // make sure word-wrap is turned on
EOL // go to EOL so that \PP\ will always work
Do_Visual("\PP\") // back up to beginning of current paragraph
WHILE(Cur_Char==32){ // delete any leading spaces
Del_Char(1)}
Format_Para(1) // wrap the paragraph with left margin 1
Do_Visual("\PP\") // return to beginning of paragraph
Ins_Text(" ") // insert three spaces for indentation
Format_Para(1) // format the paragraph again
Do_Visual("\PP\") // return again to beginning of paragraph
REPEAT(3){ // check that first three characters are spaces
IF(Cur_Char<>32){ // if character is not a space
Ins_Char(32)} // insert a space
ELSE{ // otherwise
Char(1)} // move to next character
}
Do_Visual("\NP\") // move to next paragraph


KEYBOARD MACRO VERSION:

[VISUAL EXIT] CF(W_WORD_WRAP,1) EOL Do_Visual("\PP\")
WHILE(Cur_Char==32){Del_Char(1)} Format_Para(1) Do_Visual("\PP\")
Ins_Text(" ") Format_Para(1) Do_Visual("\PP\")
REPEAT(3){IF(Cur_Char<>32){Ins_Char(32)}ELSE{Char(1)}} Do_Visual("\NP\")