Formatting options in Google Docs are limited. And that's good because formatting can be a lot of manual work (e.g. in Microsoft Word). But sometimes it would be nice to have some fine-grained auto-formatting feature like coloring a certain word if it occurs in the text.
Luckily there is Google Apps Script. You can apply some JavaScript code to your documents very easily, like for example to color some words selected with a Regular Expression:
functioncolorText(){vardoc=DocumentApp.getActiveDocument();varbody=doc.getBody();varparagraphs=body.getParagraphs();for(vari=0;i<paragraphs.length;i++){varsearchResult=paragraphs[i].findText('^.*\:');if(searchResult){varstartIndex=searchResult.getStartOffset();varendIndex=searchResult.getEndOffsetInclusive();searchResult.getElement().asText().setForegroundColor(startIndex,endIndex,'#571f4e');}}}
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse