Operations
These commands let you construct simple edit macros. The "Operations" field holds a text description of a command sequence. The "GetLast" command fills in the Operations with the description of the most recent sequence, i.e., the one a Cancel would cancel or a Repeat would repeat. "Do" executes the description in the operations field. "Begin" marks the start of a command sequence. "End" fills the Operations with the description of the commands since the most recent "Begin". "SetCom" stores the operations under the CTRL-number key for the number in the "Command [0..9]" field. Conversely, "GetCom" fills the "Operations" field with the current CTRL-number definition.
To see how this works, select the following word: "hello". Hit DEL and type in "howdy". Now hit the "GetLast" button. The Operations field should now contain: Delete "howdy". Edit the Operations field contents to replace "howdy" by "goodbye", then hit the "SetCom" button (first put 1 in the Command field if it's not already there). Now select the "howdy" you typed earlier and hit CTRL-1. If all went well, the "howdy" will have been deleted and "goodbye" inserted in its place. More examples of edit macros will be given later.
Searches and Operations on Files
You can use the EditTool to look through a list of files for one in which the current search specifications are satisfied. This can be accomplished by clicking the "SearchEachFile" button after filling in the "Files" field with the file names (or "@" followed by the name of a file that holds the list of file names). When you left-click SearchEachFile, a new viewer is created, and one-by-one the files will be loaded and searched until a match is found. The list of files will be updated when a match is found, so that when you are finished with one file you can left-click SearchEachFile again to look for the next one. You can hit the "Stop" button at the top of the EditTool to interrupt the search, but you should not try doing other operations while the search is in progress since it resets the selection each time it loads a file.
Occasionally you will want to apply certain operations to an entire set of files. You can do this by filling in the "Operations" field and the "Files" field, and then clicking "DoForEachFile". A new viewer will be created, and one-by-one the files will be loaded, selected, edited, and saved. No confirmation is required for the saves, so the entire process can go on without you. In fact, you should not try to do anything else while this is going on since the operations use the primary selection. The one exeception is the "Stop" button which you can hit to terminate the process.
Edit Commands
This section of the Edit Tool contains buttons for all the basic edit commands. These are useful if you can't remember what keys to hit for an infrequent command or if you've set your user category to beginner or intermediate to filter out certain commands. Many of the buttons correspond to commands that have been documented above. However, a few of them are primarily of use in constructing edit macros and have not been mentioned before. For completeness, all the buttons will be given a brief description.
Modifying selections
CaretBefore — move caret to front of selection
CaretAfter — move caret to end of selection
CaretOnly — reduce selection to a caret
Grow — selection grows in hierarchy of point, character, word, node, branch
Document — select entire document
PendingDelete — make primary selection pending delete
NotPendingDelete — make primary selection not pending delete
MakeSecondary — make the primary selection become the secondary selection
MakePrimary — make the secondary selection become the primary selection
CancelSecondary — remove the secondary selection
CancelPrimary — remove the primary selection
Copy, Move, and Translate
ToPrimary — copy/move secondary to primary
ToSecondary — copy/move primary to secondary
Transpose — transpose the primary and the secondary
Moving the caret
GoToNextChar — make primary caret only and move one character toward end of document or one toward start if you right-click instead of left-clicking
GoToNextWord — like GoToNextChar, but move toward end by "words" or one toward start if you right-click instead of left-clicking
GoToNextNode — move caret one node toward end or one toward start if you right-click instead of left-clicking
Saving and Restoring the selection
SaveSel-A — save primary selection to restore later
RestoreSel-A — restore the selection previously saved by SaveSel-A
SaveSel-B — save primary selection to restore later
RestoreSel-B — restore the selection previously saved by SaveSel-B
Extend the selection to matching brackets
(...) — extend primary selection to matching parens
<...> — extend to matching angle brackets
{...} — extend to matching curly brackets
[...] — extend to matching square brackets
"..." — extend to matching double quotes
`...' — extend to matching single quotes
-...- — extend to matching dashes
... — extend to matching placeholder brackets
Find placeholders
Next... — move primary selection to next placeholder
Prev... — move to previous placeholder
Delete and Paste
Delete — delete the primary selection
Paste — insert saved text at caret
SaveForPaste — save text for later pasting; overwrites text saved by Delete
Repeat and Undo
Repeat — repeat the last command sequence
Undo — undo the last command sequence
Deleting character/word next to caret
BackSpace — delete the character to the left of the caret
BackWord — delete the word to the left of the caret
DeleteNextChar — delete the character to the right of the caret
DeleteNextWord — delete the word to the right of the caret
Inserting matching brackets around the selection
Add( ) — insert parens around the selection
Add< > — insert angle brackets
Add{ } — insert curly brackets
Add[ ] — insert square brackets
Add" " — insert double quotes
Add` ' — insert single quotes
Add- - — insert dashes
Add — insert placeholder brackets
Capitalization
AllCaps — make the selection upper case
AllLower — make the selection lower case
InitialCaps — make the words in the selection start with caps
FirstCap — make the selection start with a cap
Special characters
MakeOctalCharacter — convert the 3 digits before the caret to the corresponding character
MakeControlCharacter — convert the character before the caret to a control character
UnMakeOctalCharacter — convert the character before the caret to 3 digit representing its character code
UnMakeControlCharacter — convert the control character before the caret to a normal character
Tree structure commands
Break — break node at caret
Join — join caret node to one before it
Nest — move selection deeper in tree
UnNest — move selection higher in tree
Miscellaneous commands
CommentNode — set Comment property of all selected nodes to TRUE
NotCommentNode — set Comment property of all selected nodes to FALSE
ExpandAbbreviation — expand the abbreviation to the left of the caret
MesaFormatting — add Mesa looks, formats, and style to selection
Command 0 1 2 3 4 5 6 7 8 9 — do saved command macro
Writing Edit Macros
A few examples should get you started writing your own edit macros. First, assume you find yourself doing a lot of edits of the form <stuff> becomes <pred>[<stuff>] for various values of <stuff> and <pred>. You might like a single command to insert the brackets and move the caret to the place where you will insert the <pred>. To construct such a command, first select a particular <stuff>, hit the Add[ ] button in the Edit Tool, the CaretBefore button, and the GoToNextChar button using the right mouse button. Then hit GetLast to fill the Operations field, enter "1" in the "Command [0..9]" field, and hit SetCom to save the macro definition. Now you can select <stuff>, hit CTRL-1, and be ready to insert before the left bracket.
A macro to delete matching parentheses will show the use of the SaveSel and RestoreSel commands. Make a selection anywhere inside a pair of matching parens. Give the following sequence of commands: (...) to extend the selection, CaretAfter to position the caret at the right, SaveSel-A so we can restore the selection later, BackSpace to delete the right paren, RestoreSel-A to get the selection back, CaretBefore to move the caret to the front, and finally DeleteNextChar to delete the left paren. Now you can hit GetLast and SetCom to save this macro.
Other operations on the Edit Tool can also be programmed using edit macros. For example, assume you want a macro to substitute "which" for "that". The following set of commands will load the target and replacement fields and do the substitute: right-click to select and clear the target field, type "that" as the target text, right-click to select and clear the replacement field, type "which" as the replacement text, and finally hit the Substitute button. This macro will only change the target and replacement fields. The other parameters of the substitute are not changed and thus behave like "free variables" of the macro. If you want to bind more of the choices, such as Match Case or Ignore Case, you simply include those commands as part of the macro. For example, you could select Ignore Case just before restoring the selection, and the macro would always set the ignore case flag when it was executed. Note that you must hit the "Target" and "Replacement" buttons to enter the target and replacement text. Directly selecting in those fields would not produce a correct macro because it would terminate the edit sequence and would also fail to identify which field was being filled in.
When you save an edit macro under a CTRL-number key, it only stays around for the rest of the session. If you want to save one for tomorrow, you can of course copy the operations to a file and redefine it another time. But if you really want to make a macro a permanent part of your user interface, you can add it to your "TIP table" which describes the translation from keyboard and mouse actions into executable tokens such as those in edit macros. The details of how to do this are given in a later section.