Google-docs – Inserting replaceable text for later

google docs

I don't know how this functionality is called, but I think Word had it for years. Basically, I want to do something like this:

{Character1} just got out of his bed when he heard a loud noise outside.

Where every instance of "{Character1}" is replaced later with "John":

John just got out of his bed when he heard a loud noise outside.

No, I'm not looking for a simple search and replace function, I want to know if I could add commonly used words, like a name in a story for example, to some sort of database and refer to that in the text, so that if I ever end up changing the name of the character, it will automatically get replaced everywhere.

Is there a functionality like that in Google Docs? If not, how is it called in Word? I've been looking for it forever, I just don't know how to refer to it.

Best Answer

I have the perfect solution for you. The new Google doc add-on "Reversible Formulas" enables you to insert and evaluate formulas in your Google document.

It offers three ways to achieve what you are looking for.

Simpler way: No formulas needed

Write in your doc:

John just got out of his bed when he heard a loud noise outside

Select "John". On the side panel replace "x" by "Character1" and click on "Name Selection"

Now every time you want to reuse this name, click on the newly created button "Character1" that appeared on the side panel. You can rename your character using the input on the right of the button, or rename it anywhere in the text and click on "Display values" to synchronize all occurrences.

Programmer way: Declare names explicitely

Write in your doc:

Character1 = John
=Character1 just got out of his bed when he heard a loud noise outside

Now click on "Display values". The declaration stays, but the formula is replaced by "John". You can write anywhere in the document =Character1 and later click on "Display Values" to have it replaced by "John" (you could also do in in the previous approach :-)). And as before, you can rename the occurrences of John anywhere in the doc or in the side panel.

Expert way: Declare names implicitly

Write in your doc:

=Character1@("John") just got out of his bed when he heard a loud noise outside

Now click on "Display values". This is the equivalent of the "Name selection" button that you used in step 1, It's just that it inserted a formula with this syntax, so that it records the name of the value.

The add-on can be installed here: https://workspace.google.com/u/0/marketplace/app/spreadsheet_cells_in_javascript_fields_s/159836395898

Disclaimer: I'm the author of the add-on