Macro/Shell Extensions

## Learn/Replay

Selecting Learn Keystrokes from the Macro menu puts NEdit in learn mode. In learn mode, keystrokes and menu commands are recorded, to be played back later, using the Replay Keystrokes command, or pasted into a macro in the Macro Commands dialog of the Default Settings menu in Preferences.

Note that only keyboard and menu commands are recorded, not mouse clicks or mouse movements since these have no absolute point of reference, such as cursor or selection position. When you do a mouse-based operation in learn mode, NEdit will beep (repeatedly) to remind you that the operation was not recorded.

Learn mode is also the quickest and easiest method for writing macros. The dialog for creating macro commands contains a button labeled "Paste Learn / Replay Macro", which will deposit the last sequence learned into the body of the macro.

### Repeating Actions and Learn/Replay Sequences

You can repeat the last (keyboard-based) command, or learn/replay sequence with the Repeat... command in the Macro menu. To repeat an action, first do the action (that is, insert a character, do a search, move the cursor), then select Repeat..., decide how or how many times you want it repeated, and click OK. For example, to move down 30 lines through a file, you could type: <Down Arrow> Ctrl+, 29 <Return>. To repeat a learn/replay sequence, first learn it, then select Repeat..., click on Learn/Replay and how you want it repeated, then click OK.

If the commands you are repeating advance the cursor through the file, you can also repeat them within a range of characters, or from the current cursor position to the end of the file. To iterate over a range of characters, use the primary selection (drag the left mouse button over the text) to mark the range you want to operate on, and select "In Selection" in the Repeat dialog.

When using In "Selection" or "To End" with a learned sequence, try to do cursor movement as the last step in the sequence, since testing of the cursor position is only done at the end of the sequence execution. If you do cursor movement first, for example searching for a particular word then doing a modification, the position of the cursor won't be checked until the sequence has potentially gone far beyond the end of your desired range.

It's easy for a repeated command to get out of hand, and you can easily generate an infinite loop by using range iteration on a command which doesn't progress. To cancel a repeating command in progress, type Ctrl+. (period), or select Cancel Macro from the Macro menu.