I have my cursor at the first position and would like to use the Tab key to move the cursor to replace the %<…>% text. Is there a clean way to do this?
I'm not sure exactly what you mean by this. Please clarify.
Please post exactly what you want after the movement and replacement.
I'm not sure if you mean just the first occurrence, or all occurrences of %<...>%
I expect this to be easy, using Type a Keystroke Actions and a simple Search/Replace using RegEx. But I need to be clear on exactly what you want first.
The syntax %|% is one of the commands to place a cursor. What is supposed to happen is that once I type command+m (the apple command key and m) this text appears:
The cursor is moved to the location where %|% is. In text typed above, the ampersand is a delimiter so that a matrix is created. What I want to do is to type something at the location %|% and then press Tab. When I press Tab the text %<…>% is highlighted so that when I type anything that text (the %<…>%) is deleted. Then, when I press tab again this process is repeated to fill all the spots, one by one.
The %<…>% is really just a placeholder field that I want to replace with anything that I type. The point of the Tab I suppose is to highlight the next %<…>% encountered.
OK, I don't know anything (never even heard of) either of those apps.
So, I'm assuming that Overleaf does not support placeholders, correct?
And you want to build a KM macro that does, correct?
I think the choices are:
Build a complex completely in KM that finds each placeholder, and allows your replace it.
Use BBEdit
The text you posted, is this just something you made up?
Are the number of placeholders fixed, or do they vary?
If fixed, it would be very simple to present a Prompt for User Input with one KM Var for each placeholder, and then generate the required output string.
Again, it would be really helpful if you would post EXACTLY:
The problem is that that macOS does not allow access to arbitrary text editing venues, so it's not possible to get information about them or move the cursor to a desired position in an organic way. (Unless the given venue (app, field, etc) is highly scriptable.)
The only way is to copy existing text, find what you're looking for and then force the UI to move the cursor. It's clunky and slow, but it can be better than doing things manually under some circumstances.
One thing you can do is to use the Set Find Pasteboard action to set the system find pasteboard to text you want to search for such as:
%<...>%
Then ⌘G to the next field.
This will work in Safari and any app that uses the system's find pasteboard.