Tag Archives: bold

Fun with find & replace: trailing punctuation

A colleague found herself faced with a formatting problem: the book she was working on required trailing punctuation (commas, periods) to match the formatting of the word they trailed (bold, italic). This can be hard to spot, and tedious to do by hand. She was working in MS Word. Was there a way to do it in find-and-replace using wild cards?

The answer is yes, and it involves one of my favourite F&R subterfuges, the dummy character.

It’s a bit of a nuisance that Word can specify formatting only over a whole search term, not part of one. But dummy characters help get around that:

1. Replace all bold whole words with the same word plus a special character used nowhere else in the document (a per-thousand sign or a pilcrow or a double dagger or whatever, but it has to be used nowhere else).

The find field will look like this: (<*>)
It will have “Use Wildcards” and “Font: Bold” specified for it.
The < and > mean start and end of word; the * means any number of characters; the ( and ) define it as a single term.

The replace field will be like this if your special character is ξ:  \1ξ
(Replace ξ with whatever character you use.)
The \1 refers to the first (and in this case only) defined term from the Find field.

2. Search all instances of that character followed by a comma or a period (or whatever trailing punctuation you want to change – but only one at a time) and change them to bold.

This is just changing ξ. (or whatever special character and whatever trailing punctuation) to bold, no wild cards needed (make sure to remove the format specification on the Find field). In fact, don’t use wild cards; . is a special character in wild cards (you’d need to make it \.).

3. Delete all instances of the special character.

In other words, find ξ (or whatever your character is) and replace it with nothing – completely empty cell, not even a space. Make sure to remove all formatting specifications.

4. Do the same but with italic rather than bold formatting.

The bolding and italicization should be done as separate steps. Reduces possible confusions, and also handles bold italics neatly.

This can also be used for preceding punctuation, e.g., opening quotes. The variation is trivial and is left as an exercise to the reader. 🙂

Advertisements