The last time I talked about using color as a word-processing tool, I learned that I’m not the only one who finds it easier than other methods of achieving the same results—not to mention prettier. But I also heard from my colleague and favorite tech guy Russell Harper (as I knew I would), who holds to a somewhat higher standard in these matters.
In his kind and patient way, Russell pointed out how my advice, while feasible and appealing, could in the wrong hands cause technical difficulties, not to mention pain and suffering, if not actual mortality. (Those weren’t his exact words, but that’s the way I heard them.)
“I feel relatively strongly about this issue,” Russell wrote, “because I want readers of chapter 2 of the Manual—especially 2.77—to wade into the wildcard zone.* Using wildcards is generally the most powerful approach to search-and-replace. And it can be really fun! And please note, it does not preclude the use of color.”
So this time, I’ll show how to use color in searching-and-replacing tasks, with Russell’s added advice for those who want to ramp up their skills to another level.
Using Color to Delete a Space
Color comes in handy when you want to replace some but not all instances of something. For instance, it’s common for citations in notes and bibliographies to be inconsistent in spacing after colons. In half the citations you’ll find 4:15, and in the other half, 4: 15. Let’s say you want to delete the spaces globally.
First, you have to find them. It’s no good searching for a colon plus a space, because that would include word spaces after colons: like that. You could search for colon + space + number using ^# to find numbers (type : ^#), but then what do you type in the Replace box? Unfortunately, ^# is not an option in MS Word.
At this point, rather than look up how to do this with pattern-matching tricks, many editors would resign themselves to fixing the spaces one by one. For those who would find this rewarding, I’ll host a special session sometime with tips on introducing more errors into your manuscripts, just so you can correct them.
But you and I can use color. Put number + colon + space + number in the Find box (^#: ^#). Choose a color to put in the Replace box—let’s say orange.** Replace All. You’ll see that all the numbers + colons + spaces + numbers are now orange. Finally, do a new search for colon + space in orange and replace with just a colon (it doesn’t matter if the Replace box is still tagged with color formatting). All done!
Tip: If you leave the color in your document after a replacement, it will catch your eye as you read, prompting you to check each one. When you’re completely done editing, you can Select All and restore the text to black.
Using Color to Add a Space
Similarly, you can use color as a shortcut to add a space—for instance, between closed-up initials in names like J.C. Jackson. Although the easiest way to insert a space after every period in a document is to find all periods (.) and replace them with period + space (. ), it’s not the safest way: you’ll catch in your net periods that don’t take spaces, such as those in URLs or abbreviations.***
Instead, find all letter + period + letter combinations (^$.^$), and replace with a color, say purple. Now do a separate pass for three-letter combinations (^$.^$.^$). Finally, search for all purple periods and change to period + space (. ). Simple!
Russell: Yes, but I’m afraid it’s a little too simple. This second example could be dangerous in any type of document that has a lot of specialized abbreviations. It will also end up targeting lowercase letter combinations, such as “e.g.” and “i.e.”
Carol: Oops. I actually knew that. One way I deal with it is to start things off by globally changing “e.g.” and “i.e.” (and any other exception I’ve noticed in the document) to another color so as not to catch them in my sweep.
Russell: But then you start to cause as much work as you save! This is where wildcards are more flexible than colors. In this case, it’s as simple as this (make sure the wildcards option is selected):
Find box: ([A-Z].)([A-Z].)
Replace box: \1 \2
(No space between parenthetical elements under Find; space between elements under Replace.)
Carol: Hold on a second, Russell. What do \1 and \2 stand for?
Russell: They stand for whatever is found by the expressions in the first and second set of parentheses, respectively. This gives you the power to find something and replace it with the same thing but modified (in this case, by the addition of a space).
Carol: So in your example, there’s a space between \1 and \2 (but no space after \2).
Russell: Right. This method is better for several reasons:
- It will treat only capital letters—that is, ignoring “i.e.” but not “I.E.” (A-Z is not the same thing as a-z.)
- It requires just one routine, though you should run it a second time through the document to get instances of “A.B.C.”
- You can slow things down by using the Find and Replace boxes the first time around to selectively change each item, ignoring an abbreviation like “U.S.” (or changing it first to “US” if you wish).
- You can still put a color in the Replace box if you wish to be able to see the results (without tracking changes).
This business of parentheses and corresponding numbered replacements is very easy to use and very flexible. It applies equally to your colon and numbers example, where you’d search for any digit followed by a colon and a space, followed by another digit. The first digit plus colon would be put in parentheses, as would the second digit, with a space in between. The items found by the parenthetical expressions would be replaced with the existing content, but without the space between:
Find box: ([0-9]:) ([0-9])
Replace box: \1\2
Carol: Okay, you’ve convinced me: this is cleaner and safer. It isn’t as easy to remember, but with practice it will be a cinch—and it will be just as pretty if I put my favorite colors in the Replace box. Russell, thank you!
Readers, in closing, I’d love to hear whether you love or hate these word-processing tips. Feel free to let me know. I might even be able to talk Russell into stopping by now and then.
_____
*Microsoft Word’s wildcards are also called regular expressions, which is what OpenOffice.org Writer calls them. The examples in this post, tailored to Word, can be adapted to work in Writer.
**In Word 2007, put your cursor in the Replace box, choose Format, Font, and pick a color. Make sure there is nothing, not even a space, in the Replace box. As long as the Replace box has only the color formatting, the text specified in the Find box will stay put, newly painted with your chosen color.
***Global changes are always dangerous. There are bound to be instances not found in your search, and you’re bound to change things you shouldn’t. As a rule, it’s best to make such corrections only during the initial cleanup of your manuscript, so you’ll notice any glitches as you edit. Russell: I agree. Unless you’re absolutely confident that the pattern is limited to a particular scenario, you should do the replacement case by case.