in Editing

What's Your Handle?

When faced with a situation requiring a complex find and replace in Microsoft Word, many people have no idea even where to begin. If you're one of those people, here's the secret: Find the handle.

What do I mean by "handle"? Something your find and replace routine can grab onto to do what it needs to do. For example, a few weeks ago I was faced with a 500-page manuscript that had no style formatting for its different text levels--something I'm sure your authors would *never* give you.

Basically, the text looked like this (but there was a lot more of it, of course):

This Is a Heading

This is some text. And more text. And more. And really several paragraphs more.

JML

This Is a Heading

This is some text. And more text. And more. And really several paragraphs more.

ED

This Is a Heading

This is some text. And more text. And more. And really several paragraphs more.

CBD

So there I am, badly needing styles to be applied and yet not wanting to do it by hand. The first thing I looked for was a handle--some regularly occurring pattern that I could find and then replace with itself but now with a style applied. Since this author, like most authors, was utterly ignorant of the proper way to put line spacing in front of a heading (by modifying "space before" in the heading style), he'd inserted two extra carriage returns in front of every main heading--and nowhere else. There was my handle!

So, after calling up the Replace dialog (Edit > Replace), I typed this into the "Find What" box:

^13^13^13(*)^13

And I typed the Find What Expression code, surrounded by carriage returns, into the "Replace With" box:

^p1^p

Incidentally, you can learn more about all of the wildcards in this article in my paper "Advanced Find and Replace in Microsoft Word," which you can download--free!--here:

http://www.editorium.com/ftp/advancedfind.zip

After typing in my find and replace strings, I clicked the More button to display the other Find and Replace options. I clicked the Format button, then "Styles," and then "Heading 1" so the replaced text would be formatted with that style. I put a check in the "Use Wildcards" checkbox. Then I clicked the "Replace All" button.

Ta-da! All of my main headings (and author attributions) were now formatted with the Heading 1 style.

So, how about those author attributions? There sure were a lot of them--each on its own line at the end of each short article. And each one was simply the author's initials--JML, ED, CBD, and the like. There was my handle--two or more capital letters preceded and followed by a carriage return.

In the "Find What" box I typed this:

^13([A-Z]{2,})^13

And in the "Replace With" box I typed this:

^p1^p

Again, I clicked the Format button, then "Styles," and this time "Heading 2" so the replaced text would be formatted with that style. I made sure the check was still in the "Use Wildcards" checkbox. Then I clicked the "Replace All" button, which formatted all of those authors' initials with the Heading 2 style.

The final thing I needed to style was the paragraphs between each occurrence of Heading 1 text and Heading 2 text. There were no obvious handles associated with that text, but it did have those styled headings above and below it. Could I use those for my handles? Yes, but first I'd need to mark them with some arbitrary codes. Why? Because there's no way to find Heading 1 *and* some text *and* Heading 2, all in one pass. So here are the searches (this time with "Use Wildcards" turned *off*) that I used to mark those headings:

Find What:

Heading 1 formatting

Replace With:

^&

Find What:

Heading 2 formatting

Replace With:

^&

That left me with an

code at the end of each Heading 1 (really, at the beginning of the paragraph following it) and an

code at the beginning of each Heading 2. Excellent handles indeed!

My final step was to search for those codes and the text between them, removing the codes and styling the text as Body Text. Piece of cake:

Find What (with "Use Wildcards" turned on):

(*)

Replace With (formatted with the Body Text style):

1

And that did the job. I still had some cleanup to do (like eliminating double carriage returns), but by looking for the handles in the text I was editing, I was able to style a 500-page document in less than five minutes.

The next time you're faced with a similar chore, don't just slog through the document doing everything by hand. Instead, see if there are some handles that will let you automate the whole process. You won't always find them, but you'll find them often enough to make the effort well worth your while. Please note that you should always back up your documents and run your find and replace routines on some test documents before proceeding with the real thing.

If you spend much time doing the kind of thing this article describes, you really should try our RazzmaTag program, which will automate a whole raft of complex find-and-replace operations over a whole raft of documents. You can learn more here:

http://www.editorium.com/razzmatag.htm

_________________________________________

READERS WRITE

Eric Fletcher wrote:

Late last year as part of a message I sent you regarding styles, I mentioned my use of Word 2002's Task Pane. I've been using it a lot and have found it to be an extremely useful tool in more ways than I'd thought. But don't rely on the built-in Help: it is particularly sparse and almost makes it look like the feature was added at the last moment. Here are some of my observations in no particular order.

1. I've made a tool button to be able to pop the Task Pane up whenever I need it. I have two monitors, so I float the task pane (and other toolbars) in the second one most of the time. However, on my wife's single monitor, a button makes it easier to be able to hide and restore the Task Pane (instead of the View | Task Pane menu). You can use a preset button or make your own.

2. The Clipboard panel holds up to 24 elements as you cut or copy. A 25th pushes the first off the stack. You can paste any item by clicking on it, but be aware that a right click lets you delete a clipboard item. This is handy when you need to cut something in a series of copies, or if you inadvertently copy something you don't really need. The feature has the utility of the old "spike" function but lets you manage the contents in a way Spike never did. Excel users should note that the Word and Excel task panes share the same content, so copying between the two is easy. (Very handy for ad hoc copying of addresses from Excel to Word when a mail merge is too much bother!)

3. The Styles and Formatting panel (S&F) has some very useful features for cleaning up document formats. If you've ever examined a Word file in a text editor, you may have noticed how all formatting is collected at the end and each different instance has pointers back into the text where it is to be applied. S&F appears to use this to great advantage: each different instance of any type of formatting can be listed in the S&F panel depending on what you choose to show via dropdown at the bottom of the panel.

The feature is not particularly intuitive, so open a document and try it. Consider a document with a few levels of headings and some manually applied formatting. Bring up the Task Pane and set it to the S&F panel. When you click on a subhead--say Heading 3--in the text, the S&F panel will display the style name at the top. If the selection is a variant of the defined style, the difference(s) will be noted: for example, "Heading 3 + Garamond" when I set a Heading 3 to the Garamond font. But click to the right side of the box and pull down the list to see the options:

Select all XX Instance(s) lets you select all instances within the document but also gives you a *count* of how many there are. (This is very useful if you need to do a count of instances of a particular style: how many bibliographic references are there in this document? Is this the only time I used a Heading 5?)

Clear Formatting removes formatting from the selection.

New Style brings up the dialog to make a new style based on the selection.

Modify Style lets you change the style definition.

Reveal Formatting switches to a different panel to give you all the specific formatting details.

But with the selection still in the modified Heading 3, scroll down and look at the options available for the "Heading 3" style: "Update to match selection" lets you modify the defined style to match the selection in one step. Very useful!

The other different option is Delete. This removes the style definition but doesn't delete the formatted content. In fact, it appears to have the same effect as the "Clear formatting" style selection. Particularly if I am in the process of preparing a template, I like to go through and remove any unnecessary style definitions before finalizing it.

3. When there has been a lot of "fiddling" done to make pages fit, a document can often have numerous variations on style (for example, "Body Text + Condensed by 0.1pt" or "Body Text + Before: 4pt"). If you need to re-use such copy, these variations can create headaches later. Use the S&F panel to browse through and eliminate all such variants. (I use it to remove all extraneous variations to prepare copy for conversion to HTML since I then don't have to deal with manually removing all the code Word prepares for me.)

4. Use the "Show" dropdown in the S&F panel to manage what formatting is displayed. The "Formatting in use" shows only the formatting used within the document (styles and variants of them); "Available formatting" adds the styles defined for the currently-applied template; "Available styles" lists only the styles and without the variants; and "All styles" displays the styles from the current template plus the names of Word's "built-in" styles. This latter option is lengthy, but you can pare it down by choosing "Custom . . ." and selecting which styles you want to have displayed.

Use the Custom pulldown to define what variants should be displayed (font, paragraph, bullet & numbering) and to add the "Clear formatting" option to the style list (which also puts it at the top of the style toolbar pulldown, incidentally). The selection of styles to make visible or not changes by the category selected. Finally, you can save the options in the template so it is set for other or later use.

5. The Reveal Formatting panel (RF) shows all the details about the format of the current selection. If you select "Distinguish source style" at the bottom of the panel, the display shows the underlying style and any differences--showing the detail much as the variants are shown in the S&F panel. The pulldown options for the selection let you clear formatting, choose all other similar formatting in the document, but also change the format to match the surrounding text. I'm not entirely sure what rules are used for this: a word set with French language was set to English but only if I selected the whole word; but a word set in green was changed to black when the selection was within the word.

Select something and then turn on the "Compare with another selection" checkbox. A second box appears, and when you make a second selection, the panel itemizes the differences.

My documents are cleaner and smaller since I've incorporated the Task Pane into my set of Word tools.

Many thanks to Eric for these useful revelations.

_________________________________________

RESOURCES

Jean Hollis Weber has done it again with her article "Escape from the Grammar Trap," now available on the TECHWR-L site, here:

http://www.raycomm.com/techwhirl/magazine/writing/grammartrap.html

The article explains why editors too often focus on details and not the bigger picture; how much attention they should pay to formal rules of grammar, punctuation, and usage; and how they can distinguish between essential and nonessential rules. I've worked with many editors and proofreaders who could benefit from Jean's words of wisdom.

Like the article? Be sure to check out Jean's books, newsletter, and other goodies at her Web site, the Technical Editors' Eyrie:

http://www.jeanweber.com/

Webmentions

  • Lyonizing Word: We Can Do This the Easy Way, or . . .

    […] more on this, please see my article “What’s Your Handle?” (2003) at the Editorium […]

  • Lyonizing Word: From Easy to Impossible — Three Variations on a Theme | An American Editor

    […] unique elements we can grab to carry out our search. (For more on this, please see my article “What’s Your Handle?” [2003] at the Editorium […]