Software

Quickly replace multiple space characters with a tab character

Replacing multiple spaces with a tab can be a nightmare, unless you know this simple Find and Replace trick.

Word processing has been around for a long time, and the techniques seem ingrained in our psyche. Yet every once in a while, I run across a document that uses multiple spaces instead of tabs to align text. The result is often a big mess. There are three ways to fix this problem:
  • Manually replace the multiple space characters with tabs.
  • Use several Find and Replace tasks, which is a bit faster than doing it manually.
  • Use one Find and Replace task to replace each instance of multiple space characters with a single tab character.
I know which one I'd choose! To replace multiple and consecutive spaces with a single tab character, do the following:

  1. Choose Replace from the Edit menu (or press [Ctrl]+H) to open the Find And Replace dialog box.
  2. Click the More button.
  3. In the Find What text box, enter one space character and the following characters, exactly as shown: {2,}.
  4. In the Replace With control, enter ^t.
  5. Check the Use Wildcards option.
  6. Click Replace All.
  7. Click Close.
The {2,} component tells Word to find two or more of the literal character, which in this case is a space character. You could use this component to find other multiple characters. The ^t component represents a single tab. To replace the spaces with more than one tab, simply add one ^t component for each additional tab. Keep in mind that this technique will replace every occurrence of multiple and consecutive space characters, including some you might not want to replace with a tab. If you want to retain a legitimate occurrence of multiple spaces, select only the text that you want to run the Find and Replace task against before executing it. Or click Find Next so you can review the occurrence to decide whether you want to replace it or not. This replace trick will work in any Office application, not just Word.

About

Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.

Editor's Picks

Free Newsletters, In your Inbox