isotropic-2022
Share
Blog
Search
Menu

Search & Replace in Gutenberg

By James LePage
 on July 12, 2020
Last modified on January 7th, 2022

Search & Replace in Gutenberg

By James LePage
 on July 12, 2020
Last modified on January 7th, 2022

In this article, we wanted to discuss adding search and replace into the Gutenberg editor. For many writers, this is a necessary feature. We’re included in that mix, as we typically miss capitalizations of product names. Instead of having to go back and find/edit every single word, searching and bulk replacing everything at once saves a ton of time.

Microsoft Word has a great search and replace feature (it’s actually called find and replace) which works like this. Simply enter the word that needs replacing, enter what it will be replaced by, and click "replace all".

Many other writing platforms have this feature, yet Gutenberg does not have this built into the core functionality of the editor.

There's been some activity regarding this feature from other writers:

https://wordpress.org/support/topic/search-replace-in-Gutenberg/

One would think that this is a fairly easy feature to implement, yet it hasn't been done yet. We decided to hunt around for a plugin or software solution that would allow us to add search and replace in Gutenberg.

There are two main ways (that we found) to search and replace Gutenberg content. Both aren't a great solution, and it may just be easier to create content in Word, find and replace what needs to be found and replaced, and then upload it to your Gutenberg editor.

Method One: TinyMCE Advanced Plugin

The closest functionality can you get to the find and replace interface that can be accessed via Microsoft Word would be by installing the tinyMCE advanced plugin.

This plugin adds a lot of functionality to the tinyMCE editor (which is the same thing as the classic editor in WordPress), such as table creation, advanced formatting, and more. This applies to the classic editor block that can be added to the Gutenberg interface.

Access the feature by going to the edit menu, and selecting find an replace. Once you've clicked on it, this modal box will pop up allowing you to find a specific word, and replace it with whatever term you need. You can match case, select whole words, and more. You can selectively find it replace, or replace everything at once.

Unfortunately, this tool only works for content that is within the individual classic editor block in the Gutenberg editor. It won't replace all content (which is what we want), and kind of defeats the purpose by requiring all of the content to be within the classic editor block.

However, there are some work arounds to this issue. You could write all of your content initially within one classic editor block, utilized the find and replace function , and then cut the content from the classic editor block and paste it into the Gutenberg editor.

If you have properly broken up the content (this works with images as well) pasting it into the Gutenberg editor will automatically apply the lock styling for each individual content type.

Also, if your workflow involves uploading word files to the Gutenberg editor, Mammoth (the tool that is used to do that) automatically inserts all of the content into one classic editor block, which you then need to copy and paste into the Gutenberg editor. That means that you can upload the document, find and replace within the classic editor, and then copy and paste out of it (however, we would probably just end up using the search and replace feature built into word before doing this anyway).

Method two: General Search And Replace (plugin or WPCLI)

If you don't need to be targeted with your search and replace, you can simply install a plug in That will search for a word throughout the specified database tables and replace it with your query. You can also do this on WordPress CLI, though again, this isn't a targeted method which is what most authors are looking for.

Conclusion

Again, our main recommendation is simply writing all of the content in Word, and then uploading it to your WordPress website. This method carries across the HTML styling as well as images included in the word document, though we’re still missing the search and replace feature in Gutenberg.

We've filed a request for this feature, and hopefully the core team will understand the usefulness of this edition and include it in a future release of the editor.

Subscribe & Share
If you liked this content, subscribe for our monthly roundup of WordPress news, website inspiration, exclusive deals and interesting articles.
Unsubscribe at any time. We do not spam and will never sell or share your email.
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Article By
James LePage
Contributors/Editors
notloggedin
James LePage is the founder of Isotropic, a WordPress education company and digital agency. He is also the founder of CodeWP.ai, a venture backed startup bringing AI to WordPress creators.
We're looking for new authors. Explore Isotropic Jobs.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram