Chat Gpt advises me to use Karabiner Elements and Hammerspoon for this but I'd rather not go down two new rabbit holes if Keyboard Maestro can take care of this.
Interesting question. I like this question. Sure, I think I can do it. Although you haven't defined snake case, I think it's when spaces are translated to underscores. Basically then, you want a simple macro that is triggered by a space key and types an underscore whenever it's triggered. Then you need another macro that is your hotkey for enabling or disabling that macro.
I'm not sure if that will meet all your requirements, but you haven't really stated what all your requirements are.
Thanks! I didn't test it thoroughly. I'm concerned that there might be a fraction of a second between the time you press the toggle hotkey and the time that the other macro is enabled or disabled. Let me know if that's a problem.
Inspired by your example, I tried doing one for Title Case.
=> It Works If I Deliberately Type Slower After A Space.
=> If Not = hTis sI hWat Happens.
I have tried filtering clipboard, not regexing it, same thing. Regexing it to the source for some reason does not work (thinking it might be a bit faster).
Not sure if there is an option to use the trigger regex and somehow just instantly replacing it?
Don't know how to think, any suggestions on the approach?
Nige is always putting me out of business. How is his solution working for you? I think I have found an entirely different approach.
Indeed, my approach seems to work. Although if I mash the keyboard with 25 characters per second, my method seems to make a few mistakes. I can't understand how my method could make any mistakes. I don't think it makes any mistakes for normal typing speeds, however.
Here is my solution (it's two macros in a group called "Title Case")... But if you like Nige's solution, you can stick with that.
Try "Semaphore Lock"ing the whole macro to force sequential execution as you type -- I don't think you can rely on simulated keystrokes hitting the buffer in the correct order when you've multiple near-simultaneous instances of the macro running.
Niges method works perfectly. I will have a look at yours too.
To contribute, I have made dynamic uppercase macro.
Though it might be useful for some of us that don't have a designated caps lock key and don't want to be pressing caps word before each word when typing more then one cap word.
Can't really take any credit for it since all I did is change a letter in regex using Niges method, but still.
There should be a trigger macro and the macro that does the work in the folder. (First time sharing a macro to forum)
Title Case Is On. It Is Working Perfectly. I See No Problems At All. Everything Seems To Be Working Just Fine. I Am Typing At My Normal Speed Of About 80 WPM.
snake_case:
write_some_code_here
UPPER CASE:
NOW DECLARE SOMETHING
And here is a Macro group with all three Macros and their enablers. For ease of access if anyone interested.
Thanks. If you need any changes, let me know. I recommend that you place a semaphore at the top to prevent errors that may occur when you type really fast.