TextEdit patterns (word count, character count, finding and replacing)

Written by Codemzy on December 1st, 2021

TextEdit might seem like a basic text editor. It is simple to use, with a minimal design, but it does more than it first appears. You can use the Insert Pattern feature in Find and Replace to get a word count, character count, and some pretty complex replacements!

TextEdit is a simple text editor created by Apple. You can find it pre-installed on Macs.

I use TextEdit almost daily because I love its simplicity. I mostly use it in plain text format. I can paste some text, or even some HTML, in there and get the plain text back.

This Mac app is handy if you need to remove text formatting when pasting text from one place to another. Like from a webpage to an email.

TextEdit is great for writing something simple, because you will only focus on the words. No headings, bullet points, lists, quotes. Just you and the sentence. It is minimalism on a computer!

But you are not stuck with plain text. If you want to get fancy, you can save your files in rich text format .rtf. You can do this from the menu under Format > Make Rich Text. Now you can add headings and lists to your heart's content.

Although it might not have all the bells and whistles of Microsoft Word, or Apple Pages, sometimes simple is all you need.

And don’t let its simple appearance fool you. There’s this one TextEdit feature that is a game-changer once you discover its power.

Insert Pattern.

Maybe you were looking for features in TextEdit, but you couldn't find them. Like a word count. Or perhaps you need to make lots of repetitive changes to a long body of text. Insert Pattern has the answer.

You can find Insert Pattern in the menu under Edit > Find. You can also use the keyboard shortcut for the find feature ⌘F.

The Insert Pattern feature is like a no-code Regex builder. If you don’t know what Regex (aka Regular Expressions) is, it’s a way to use code to find patterns in text.

But luckily, there is no need to know complex Regex code to use Insert Pattern in TextEdit. And once you get the hang of it, you will be flying through your text at speeds that are not humanly possible. Yep, computers are faster than humans - when dealing with text anyway!

So you can use this feature to do all kinds of cool things. Things that would be tedious (and boring) to do manually.

To use it, click the search icon dropdown (the left of the search input) and select Insert Pattern.

TextEdit insert pattern

Honestly, I use this feature so much.

Let’s have a look at some of the many things you can use Insert Pattern to do.

Word count

One of the features missing in TextEdit is a word count. And people have noticed. “TextEdit word count” is Googled over 100 times a month.

And while this feature might not be available as a menu item, it is really easy to get a word count in TextEdit when you use Insert Pattern.

Edit > Find > Insert Pattern > [Word]

TextEdit word count

And that grey number to the right-hand side of the input is the count. Now you have the word count!

Character count

So you can get a word count, what about a character count? Yep, you can do that too!

If you want to include spaces in your count, the pattern is just as simple as the word count.

Edit > Find > Insert Pattern > [Any]

This pattern will count any character, including whitespace (spaces).

TextEdit character count

It’s not quite as straightforward to use Insert Pattern to count without spaces. Instead, you can get the count of the spaces, then subtract that number from the result we got above that includes the spaces.

Get the count including spaces:

Edit > Find > Insert Pattern > [Any]

And then subtract the spaces:

Edit > Find > Insert Pattern > [White Space]

TextEdit white space

Line count

For the last counting example, maybe you want the line count for some text? You can check how many new lines you have with Insert Pattern too.

Edit > Find > Insert Pattern > [Line Break]

TextEdit line-break


The Insert Pattern feature is great for more than just counting. I think the true power of this feature shines when transforming your text.

Edit > Find > Find and Replace...

For example, if you wanted to remove all line breaks from a section of text. You could go through it manually and backspace at every new line. Or you could run a replacement pattern.

Edit > Find > Insert Pattern > [Line Break] > Replace

TextEdit line-break replace

Don't insert anything into the Replace input, and anything found will be removed. Or you might want to add a space if you are dealing with sentences.

Or maybe you have the opposite problem - a bunch of text all in one solid block that you want to add line breaks to. Patterns can do that too! You could insert a line break at the end of each sentence, for example, by looking for full stops (or periods if you are American) and replacing them with the Line Break pattern.

Edit > Find > . > Replace > . [Line Break]

TextEdit line-break insert

You can even deal with more complex replacements. For example, if you have some HTML code and want to remove every <div> that wraps a <p> tag.

Edit > Find > <div><p>[Any]</p></div> > Replace > <p>[Any]</p>

This pattern replaces the <div> tags that wrap <p> tags, keeping the contents in place.

TextEdit html replace

The Insert Pattern feature might not be a fully-fledged Regex replacement, but it can achieve a lot when your find and replace requirements are straightforward. And you can certainly get much more complex than the patterns shown here. Have a play and see what you can find!