MACRO: Replace Text Keep Initial Case v1.0.1

#Macro Library Replace Text Keep Initial Case v1.0.1

Minor Update: Retain the clipboard's contents (i.e. "Delete Past Clipbard 0") to make it possible to copy the text you want to find, then select the target text and run this macro, and be able to paste the "find" text into to the prompt.

Replace Text Keep Initial Case.v1.0.1.kmmacros (14.6 KB)

This is a little hard to explain, but VERY simple to use, so bear with me.

Using the currently-selected text, this is a standard find/replace, with the following differences:

  1. Case-insensitive search.

  2. Replaced text's first character's "case" keeps the case of the original found text's first character.

###Example:

Selected Text (I made some of the text Green so you could see what gets replaced):

Parameters:

Result:

I hope this makes sense.

2 Likes

I use a similar Case Sensitive Paste macro for this sort of thing.

1 Like

Very useful, thank you!

How can I make it so I can leave the "replace with" field blank without getting an error message? This would allow me to delete specific text in the selection without adding new text

You need to make a very small change to some JavaScript, but trust me, it's easy. Find the "Execute JavaScript for Automation" action, shown here:

Scroll it down to the bottom.

Where the red arrow is, change true to false. I'm pretty sure that should do it. Let me know if it doesn't work.

That fixed it. Thank you!!

1 Like