The text-editor has a simple but very useful macro recording/execution functionality.
By pressing the "Learn"- ("CTRL-F2") key,
every edit operation is recorded as you type it in.
This recording continues until you press the "Learn"- ("CTRL-F2") key again.
The recorded actions can be executed again, by pressing the "Execute-Macro" ("ALT-F2") key.
Using this capture/replay functionality is highly useful to perform edit-tasks,
which consist of repeated insertions, deletions, etc. on a number of lines.
For example, if you have multiple lines, say:
1 a
2 b
3 c
...
and you want to indent each, and place parenthesis around each pair (for example, to make it an array literal),
the editing can be done very quickly by using a macro:
- Move the cursor in front of the first "1"-character of the first line
- Press "CTRL-F2" to start "learning"
- Press a number of spaces to indent (or press F10 to indent the line)
- Press "(" to insert the left parenthesis
- Press "CTRL-e" (or "END")to move the cursor to the line-end
- Press ")" to add the right parenthesis
- Press "CTRL-RETURN" to move to the beginning of the next line without inserting a line break
- Finally, press "CTRL-F2" to stop "learning"
It is very useful to have the cursor positioned correctly for the next repetion
at the end of the recording (i.e. right before the character, where the macro is to be executed the
next time). If this is the case, you will not have to move the cursor manually for the next execution
(in the example above, step #7 does this).
Now, press ALT-F2 for every line that has to be processed by your macro.
You can also skip lines, and apply the macro at some other place in the text, by moving the cursor
in between macro executions.
You can also perform any other operation (such as loading another file in the file browser) in between
macro executions. The macro will be remembered until the view is either closed,
or another macro is learned.
They are meant to be used to speed up one-time operations. If there is a function which
is used often, we recommend to define it in your "keyboard.rc
" file,
and place it onto a function-Key.
Macros are not shared between text views.