Friends, it’s been a long time since we’ve talked. I’m sorry.

It’s that pesky thing called Life. I have two teenagers, a new job, and, well, just stuff that gets in the way of writing here.

But I have something to show you.

I’m working on a project that has a rather large TOC and it’s unorganized (only because of the nature of the import acrobatics that was required).

Screenshot_012415_100006_AM

The issue is with the prefix on each and every topic title. That prefix has to go…and I’m not really too keen on clicking on each entry and removing ‘Server Backup: ‘.

Instead, I need to do a search and replace. Unfortunately, on first glance, search and replace doesn’t work on a TOC file.

But then again, it does!

I right-click on the TOC file in Project > TOCs and select Open With… > Internal Text Editor. I see this (sorry for the blurring – it has to be done).

Screenshot_012415_101527_AM

Yes, it’s intimidating…and scary….but it’s now completely workable with a search and replace!

Here’s my search criteria.

Screenshot_012415_101656_AM

Essentially, I want to find every instance of “Server Backup : ” and remove it. To narrow the search and only find the instance of that string in the title tag, I make sure to select the Title=” part as well. I want to replace it with just  ‘Title=”‘

In the Find in: field, I only want to look through the open file – so I select (current document).

Selecting Find in Source Code is a good practice as well.

Now, you may choose to do this differently, but I prefer to be cautious when it comes to replacing code. Needless to say, I’m not going to click on Replace All. Instead I select Find Next.

You can see what it has selected. This is good.

Screenshot_012415_102228_AM

I click on Replace and get this result:

Screenshot_012415_102535_AM

The prefix I wanted gone….is gone!

So I repeat this process for each entry. Again, I’ve been burned using “Replace All” so I prefer not to use that method. But if you like to live dangerously, go for it.

My resulting TOC when I switch back to the TOC Editor looks like this:

Screenshot_012415_102914_AM

The prefix is gone and I’ve saved a ton of time!

I hope this helps!

3 Responses to “Search and Replace in a TOC”

  1. Jessica January 27, 2015

    Great tip about using “Title:” in the search and replace criteria. I think I’ve left that out in the past and made a few mistakes.

    I agree with you about the Replace All; it’s a no-go when working in the source code.

  2. Craig Prichard January 28, 2015

    Welcome back! We all hope you can spare a few moments occasionally to bless us with your experience and wisdom.

  3. Garry February 12, 2015

    I’m glad you are back! I look forward to your articles!

Leave a Reply?

Recent Posts