How to move the caret from markup to markup, forward delete the markup and simulate a keystroke?
Example string on the clipboard and in the editor:
Blue¥green¥white¥purple¥black
The number of markups ¥ can vary. The number of characters between the markups will vary too.
When the macro is launched, the caret is at the beginning of the string. Firstly, the caret is moved 4 characters (positions) to the right. Secondly, a forward delete is simulated. Thirdly, a keystroke Control+Option+9 is simulated to insert a tag.
Then the cursor is moved 5 positions to the right, a forward delete is simulated, a keystroke Control+Option+9 is simulated to insert a tag etc. until all markups are ‘visited’ and converted to tags.
If I’m right, the macro would at least exist of the following steps:
- Save the positions of all markups in the string (5,11,17,24 in the example).
- Calculate and save the numbers of characters between the start of the string and the first markup, and between the remaining markups in the string (4,5,5,6,5 in the example).
- Move the caret n positions to go to the next markup.
- Forward delete and insert a tag at every n positions.