Loading
scriptkit-showcase 9 exercises
lesson

Apply Title Case to Text Anywhere

Sometimes you just want to select and modify some text you have written somewhere on your system. To help you with this, Script Kit provides a getSelectedText and setSelectedText. Between these two helpers, your script and use and/or modify the text however you want.

Applying an npm tool like t

Loading lesson

Transcript

0:00 Create a script called Title Case. From here, we're going to use npm package called title-case and grab the titlecase method off of that. Then from Script Kit, we can use the await getSelectedText, which will give us the selected text.

0:20 Then we can title case the selected text, and we'll call this titleText. Then we can use the setSelectedText helper from Script Kit. We'll set the titleText.

0:35 To test this out, we'll just say, "This Is the Title of My Next Blog Post." We'll open Script Kit from title-case. Hit Enter, and you'll see it converted the text to title case.

0:48 This will work anywhere in your system. Like in this jist, we'll say, "This Is the Title of Another Blog Post." Select that. On title-case, hit Enter. You'll see everything go to title case.