I want to delete all pharagraph signs in a selected text. got a macro to do this from the forum. The problem is, I do not understand how to impliment this macro. I need something in it that says look at the selected text. I have been clueless for the last 10 years. Could you help me?
Scrub - paragraphy ty.kmmacros (5.0 KB)
Can you post a link to the original Macro - it looks like it is by Christopher Stone @ccstone but I couldn't find it when doing a search?
Paragraph signs – those Paragraph marks are just visual hints used, for example in MS Word.
For matching in a regular expression, you need \n and/or \r, depending on the source of the text.
Perhaps for example, something like the following, which replaces various patterns with a single white space character.
Cleaned para.kmmacros (6.4 KB)
Don't use a typed string trigger for this, use a hot key trigger instead -- if you have some text selected the characters you type will replace that text. Not what you want!
If you want to keep any text formatting you will need to use the Clipboard rather than a KM variable. So the simplest plan is to
- Copy the selected text
- Search and replace on the System Clipboard
- Paste the now-cleaned Clipboard, replacing the current selection
Something like this should work:
Scrub - paragraphy v2.kmmacros (2.3 KB)
This is a code ignorant person, so please forgive my lack of understanding.
Nige_S, I see what you mean, but your hotkey brought up an i with a diacritical mark above it (for Spanish I think). As you said, tyyy as a trigger does not work. Letters simply are typed into the selcted text. I need a better trigger suggestion. I was trying to follow the plan of "triggering macro by name", but again mine trigger is letters. So, it does not work here.
ComplexPoint I tried your idea for a substitution for a paragraph sign. Unfortunately, because I can not even start my macro, I could not try it.
Is it possible to copy the text into a clipboard. Then, have the macro look at that text. Then, as Nige_S suggested paste that into the text.
ComplexPoint is doing something much more "complex" than simply pasting. I do not understand. Maybe ComplexPoint has named my text %local_Cleaned% Did he/she/they expect me to do something with the text first? Such as copy it??
Finally, ComplexPoint, how is the cleaned text pasted into location of the text where I have removed paragraph marks?
Important first question: Did you ensure both the macro and the group it's in are enabled?
See the following macro is enabled by the tickmark, but the macro group is not enabled:
You could try adding it to the Keyboard Maestro Status Menu and see if you can trigger it from there.
That's unusual because Mac has native support for such characters using the ⌥ with pretty much all alphanumeric keys. For example ⌥` (that's a backtick) gives a grave `
with a cursor so you can enter the letter under it; ⌥E gives an accent ´
with a cursor for the same. I don't think there are any native keyboard shortcuts for such characters that incorporate the shift, option, control, and command keys all together, so I wonder if you have another macro doing something?
This is precisely what Nige's macro is doing. See the second action for Search and Replace, it is searching the System Clipboard
.
ComplexPoint has simply Set Variable to Text (a local variable so it isn't saved in your KM preferences) with some sample data so the macro can work on that in a controlled way and give the exact output intended. That is: after the Search and Replace action cleans it, it is saved to a new (local) variable, which is then displayed in a convenient window for you.
You can change the output of the Search and Replace action to be the System Clipboard
instead of Variable
and either disable or delete the Display Text action.
Make sure the imported macro is
- Enabled -- a tick next to "Triggered by any of the following"
- In a Macro Group that is both enabled and available in the context you are trying to run the macro in
If either of the above aren't right then the macro won't be triggered by the hot key combo -- the keystrokes pass through to the active app as normal, which is probably why you are getting the funky character typed.
I see what you are saying Nige_S. I should use a status menu because then I don't need to type.
How do I make a menu icon appear in the Mad top bar? I think it suppose to appear there. I remember a few years ago, I did something where I typed some letters and the status menu appear. I selected the macro from there.
Even then your macro won't work unless both it and the Group it is in are enabled. Sort that out first.
After that it a question of how you'd prefer to run the macro. The hot key combo will be "swallowed" by the Keyboard Maestro Engine and not reach the app so it will trigger the macro without over-typing your text. If you'd prefer to use a menu item then read about the "Status Menu Trigger".
But it sounds like what you saw before was the "Conflict Palette", which appears when you have more than one active macro with the same hot key, typed string, or device key trigger.