A Script to Flag Certain Words in InDesign
Free script to flag risk words in InDesign, so you can spot them easily and remove/replace them

If you’ve ever worked on a project where it was important that certain words not be used, you might be interested to know there’s a script that can flag those words, highlighting them in the InDesign layout so you can spot them easily and remove/replace them.
The script is by Peter Kahrel, who was inspired to write it by this forum post.
If you know about GREP styles, you might be thinking they would also work for this kind of thing, and that’s true. You could make a GREP style that flagged all the “risk” words by automatically formatting them with a character style. But GREP styles can get unwieldy when you make them search for lots of stuff. Imagine you had a list of 50 words you needed to flag. The GREP style to do that would be a pain to set up and edit, and it could slow InDesign down significantly, especially in long documents.
Peter’s script uses text conditions instead of GREP. You simply put all your risk words into a plain text file, named “risk-words.txt” in the same folder as the document.
Run the script and it will find all instances of those words and apply a text condition called Risk Word to them.
Another advantage conditional text has over a GREP style is that the conditional formatting won’t appear in any output unless you want it to. By default, it will only be visible in the layout. But you can make it appear in output by opening the Conditional Text panel (Window > Type & Tables > Conditional Text), and choosing Show and Print from the Indicators menu in the panel.
You can also quickly toggle the visibility of the conditional formatting in the layout by choosing Hide from that same menu. You could even assign keyboard shortcuts to those menu choices to really speed things up!
GREP styles are not so easy to turn on and off, and if you used one, you’d have to remember turn it off before you exported or printed the document.
Don’t like default yellow highlighting for the condition indicator? Double-click the condition in the panel to open the Condition Options dialog box. There, you can change its name, choose from various underline styles and colors.
You can download the Flag Risk Words script here.
This article was last modified on August 4, 2023
This article was first published on August 4, 2023