Replaying a learn buffer

Replaying a learn buffer is done either with the <Control>-digit combination corresponding to the buffer. Replaying a sequence in one of the buffers can therefore only be done after its learning process has been terminated.

One may replay a learn sequence of one of the lower buffers while learning in a higher buffer. The inverse is not allowed. This prevents loops and other undesirable effects. The buffers can not tell whether e.g. Alt-F4/Ctrl-4 means the replay of buffer 4 or `stop learning in buffer 4'. Therefore it is not possible to first stop the learning in the higher buffer when two buffers are learning simultaneously.

If for some reason one wants to stop the replay of a learn sequence before it has ended, this can be done by pressing both shift keys simultaneously. Once stopped, it is not possible to continue at the position where the replay was halted.

In cases when a response is required from the programmer to confirm or veto an action, the response cannot come from the learn buffer. Examples of this are when the veto flag is set during a search and replace operation, or when a buffer that has not been saved is cleared. If such commands are included in a learn sequence, the editor will pause and wait for a response from the keyboard before continuing the learn sequence.

The contents of the learn buffers can be stored in the default file with the DW command.

The best way to see the power of these learn buffers is by means of some examples. The first one is used to teach buffer 1 to declare the line that contains the cursor to be a comment line in the C language. This is done as follows. With the exception that ASCII characters to be typed are grouped together, each key stroke is spelled out in detail for clarity. Commentary is given in parentheses.

Executing a sequence in buffer 3 five times is done with :

The keys that are entered in the learn buffers are the keys after they come from the key redefinitions (p. [*]). If key redefinitions are used one may notice that the learn buffers can fill up rather quickly. Much used sequences can therefore better be programmed as a key redefinition or a macro. The learn buffers are mainly for little things that come up during a particular edit session and that have to be done several times.

There is one restriction to the actions you can undertake from a learn buffer: It isn't allowed to read a default file from a learned sequence. The reason is rather simple: the contents of the learn buffers would be overwritten by the the contents of the default file, because the defaults file contains also the learn sequences. This could lead to effects that are so interesting that they are forbidden.