4.5.6 RepeatLast

Syntax: RepeatLast [times] [F|Find|R|Replace]
Abbreviation: RL

repeats for the given number of times the last find or replace operation (with replace we mean here a single replace, even if the last Replace operation ended with a global substitution). If you don’t specify either Find or Replace, it will repeat whichever one was last performed.

If any find or replace operation runs into the end of the document (in the direction indicated by the SearchBack flag) and stops, then and only then will a RepeatLast command “wrap around” to the other end of the document to continue the find or replace operation.

RepeatLast is especially useful for researching a given number of times, or replacing something a given number of times. The standard technique for accomplishing this is:

  1. Find (or FindRegExp) the string you are interested in;
  2. if you want to repeat a replace operation, ReplaceOnce with the replacement string you are interested in;
  3. now issue a RepeatLast n-1 command, where n is the number of occurrences you wanted to skip over, or replace.

The important thing about this sequence of actions is that it will work this way even in a macro. The Replace command cannot be used in a macro unless you really want to interact with ne during the macro execution. Avoiding interaction during macros is the primary reason the commands ReplaceAll and ReplaceOnce are provided.