Home | SkillForge Blog | Microsoft Word – Replace Multiple Spaces with a Tab Character

Microsoft Word – Replace Multiple Spaces with a Tab Character

Microsoft Office, Microsoft Word

Let’s set the stage:

You receive a file from your co-worker where data has been arranged into multiple columns to create a table-like format.

word-replace-spaces-1

Upon careful examination, you notice that the column alignment is just a little bit off.  To discover the cause you press your Show /Hide button in Word to reveal the formatting codes.

word-replace-spaces-2

This reveals the nightmare that is “Beginner’s Formatting”.

word-replace-spaces-3

Not understanding how TABS work, the co-worker had brute-forced data into columns by adding however many spaces it took to achieve the desired look.

Your job is to replace all of those spaces with single TAB characters.

With data spanning hundreds of rows (what about THOUSANDS of rows), you are now facing a long and arduous task.

FIND and REPLACE to the rescue!!!

Follow these steps to mass replace every cluster of space characters with a single TAB character:

  1. On the HOME tab on the Ribbon, choose Replace from the Editing group (or press [Ctrl]+H) to open the Find And Replace dialog box
  2. In the Find What field, enter one space character and the following characters, exactly as shown in red: {2,}
  3. In the Replace With field, enter ^t
  4. Click the More button
  5. Check the Use Wildcards option

word-replace-spaces-4

6.  Click Replace All
7.  Click Close

The result will appear as follows.

word-replace-spaces-5

Now, to be perfectly honest, the list won’t look this pretty until you get your tab stops in position.  I wanted you to be excited about the trick before I threw in the caveat.

The secret behind this is that the {2,} code instructs word to locate 2 or more in sequence of whatever character you placed before the open brace { character.  You can actually place ANY character before the open brace and it will work all the same.

The ^t code represents a TAB character in Word.  If you wish to have more than one TAB, simply type multiple ^t in a row without any spaces between them (ex: ^t^t^t^t).

If there are areas of your document where you do NOT want this global replacement to occur, highlight the area to be replaced prior to executing the Find/Replace operation.

Although this scenario is almost exclusively the province of Word, the replacement technique can be used in any Office application.