Selecting Macro → Learn Keystrokes puts NEdit-ng in learn mode. In learn mode, keystrokes and menu commands are recorded, to be played back later, using Macro → Replay Keystrokes, or pasted into a macro in the Preferences → Default Settings → Customize Menus → Macro Menu... dialog.

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-ng 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 Macro → Repeat... command. To repeat an action, first do the action (that is, insert a character, do a search, move the cursor), then select Macro → 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: Ctrl + , 2 9 Return. To repeat a learn/replay sequence, first learn it, then select Macro → 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 Macro 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 + ., or select Macro → Cancel.