Native Find and Replace in Macro Editor

There's a few hacky scripts that do this but it would be nice if the native find function had a replace option as well. I want to be able to iterate through each occurrence and choose whether to replace each one, or replace all.

Hey Joe,

I'm fairly sure that's already on @peternlewis' to-do list. You are certainly not the first to request this feature.

-Chris

There are no plans to implement this at this time.

Hi everyone,

I would like to +1 on the feature request from @jpancotti (unless this feature has already been implemented -> then please let me know how to use it).

I often find myself changing a variable name to make it more descriptive. Currently (unless I misunderstand the possibilities provided by the Keyboard Maestro Editor (11.0.4)), I need to search for the name of the to-be-replaced variable, then manually scroll through the entire macro in order to spot each occurrence of this variable (highlighted by the Editor) in order to then manually replace each occurrence by the new variable name (e.g., by selecting the old variable and pasting the new one on top).

This it the process I use currently. It is not only very slow but also very error prone (For example because I unintentionally forget to select one letter of the old variable. When I then paste the new variable name, it will still have the letter of the old variable attached to it. Barely noticeable and thus difficult to debug).

As an additional feature request, I would propose a "jump to next occurrence" function for both the existing Search but also the new Search and Replace function.

@peternlewis Are there any plans to implement this in the near future? I would be very happy to see this very helpful feature to be added to the Editor!

As far as I'm aware this is still not yet possible. However, I highly recommend using the Search & Replace Macro by @DanThomas. This will allow you to import your Macro either as JSON or XML into your Text Editor of choice and there you can use Find and Replace. Then simply paste it back in the Editor. That will at least be much faster and less error prone than the method you're currently using.

1 Like

There are no current plans for this.

It is very problematic to do, even at a superficial level.

Changing a variable name, for example, would mean changes would need to be in variable fields, in text fields that are using the Variable token, in calculation fields, in scripts that are using the KMVAR_Variable_Name, in AppleScript’s accessing variables.

And yes, I could punt a bunch of that and only change it in text fields, but even then there are risks that are hard to mitigate. If you have three variables named:

  • My Variable 1
  • My Variable 2
  • This is My Variable

and you search and replace "My Variable", what are you really wanting to do?

Changing it just in Variable fields seems inadequate, since variables are frequently used in text and numeric fields. Changing it in those is difficult to do while ensuring only the desired variable is changed, or allowing changing of substrings of variables names (which you might well want to do to rename a group of related variables).

I don't tend to implement features unless I can implement them in a way that is complete and safe and comprehensible. I would rather not have a feature at all that have a half-baked feature. And in this case, it's hard to see how I would implement it in a good way.

4 Likes