Macro – Change Text To Title Case – JavaScript

A nice easy Macro to change the case of your currently selected text to Title Case that capitalises the important words.

Great when editing blog posts or other content in Google Docs or similar tools that don't have built-in case convert.

Title Case Text.kmmacros (4.0 KB)

Hey Henry,

Welcome to the forum!  :sunglasses:


It's been done before a time or two, although I think this is the first JavaScript version on the forum.

I like the compactness of the code.

I've modified it a trifle:

  • Uses the macOS Clipboard directly instead of a Keyboard Maestro variable.
    • An example of Local / Instance variable use is embedded.
  • Refactored the code slightly.

-Chris


Title Case Selected Text v1.00.kmmacros (8.2 KB)

Macro Image

Keyboard Maestro Export

1 Like

FWIW see also:

2 Likes

Just for reference, Improved Title Case Macro written in Perl also handles @ words and hashtags. That thread has a healthy discussion of the task in general, too.

3 Likes

Thank you for the warm welcome @ccstone.

And thanks for remaking the script; that also helps me understand how I can do things better for other scripts. I thought I might be the first, but it's awesome to see the other implementations. I would like to build out a library of case-converting scripts, so I'll check the forum before diving into any more macro building.

-Henry

1 Like

That is an awesome script! Thank you @ComplexPoint. I'm going to use this instead of mine as having editable lexicons is so helpful.

1 Like

Hey Henry,

Keep in mind that Keyboard Maestro's Filter Action has standard case conversions.

image

They don't always work exactly the away users want them to, which is why there are several alternatives out in the wild.

Find out if they're adequate for your needs before spending a lot of time rolling your own – unless of course you're doing that for fun...  :sunglasses:

-Chris

Possibly undefined for title case ?

(the local variability of prepositions and conventions might make it hard to attach much meaning to standard there)

They are standard for Keyboard Maestro and according to Peter's standards. I suppose I could have said rudimentary, but quibble all you want.