How to Convert Tabs to Spaces


The Tabulator, or Tab, key is a special character that advances the cursor forward. Tabs are typically used to mark a new paragraph or separate data in tables. Changing tabs to spaces may be required if you need to reformat a document. Microsoft Word has a command to replace any character within the text. The vi editor included in each Linux version also allows you to instantly replace tabs in the entire document or in specified file lines. However, special encoding is needed for the tab symbol to be used in those replace commands.

Things You'll Need

  • Microsoft Office

With Microsoft Word

  • Log in to you user account in Windows XP/Vista.

  • Click the \"Start\" button in the lower left corner of the screen.

  • Click \"All Programs\" and then open the folder \"Microsoft Office.\" Click \"Microsoft Word\" to launch the program.

  • Press \"Ctrl-O\" and browse your computer to open a file in Microsoft Word.

  • Click the menu \"Home\" and then choose \"Replace\" under the submenu \"Editing\" in Microsoft Word 2007. In Microsoft Word XP/2003, click the menu \"Edit\" and \"Replace.\"

  • Type \"^t\" in the field \"Find what.\" (Note: To type the symbol \"^\" press \"Shift+6.\") Type a space in the field \"Replace with.\"

  • Click \"Find Next.\" The first occurrence of \"Tab\" will be selected. If you want to substitute this \"Tab,\" click \"Replace.\" Otherwise click \"Find Next\" to get to the next \"Tab\" occurrence.
    Alternatively, click \"Replace All\" to substitute all occurrences of the \"Tab\" symbol by a space at once.

  • Press \"Ctrl-S\" to save the modified Word document.

In Linux

  • Log in to your user account in Linux. Right-click on Desktop and click \"Open (or New) terminal\" in the pop-up menu.

  • Type \"cd your_folder\" in the terminal window and press \"Enter\" to navigate to the folder that contains a text file.

  • Type \"vi filename\" (for example, \"vi data.txt\") followed by pressing \"Enter\" to open the file in the vi editor The file information will appear at the bottom of the editor windows. Write down or memorize the piece of number that is left to the symbol \"L\" (for example, 50L). This is the number of lines in the file.

  • Press \"Esc\" on the keyboard and type the following string in the bottom of the \"vi\" window:
    \":1,50 s/\t/\s/g\" and press \"Enter.\" This command replaces all occurrences of \"Tab\" in the file. Note that \"50\" is an example that is the last line in the file (see Step 3), while \"1\" refers to the first line. Also you can use this command as follows:
    \":2,4 s/\t/\s/g\" -- replaces all \"Tabs\" by spaces in the lines two to four.
    \":1,50 s/\t/\s/\" -- replaces only the first occurrence of \"Tab\" in each line.

  • Press \"Esc\" on the keyboard and type \":wq\" to save the file and quit the vi editor.

Related Searches


  • “Microsoft Office 2007 Simplified”; Sherry Willard Kinkoph; 2007
  • Basic Vi Commands
Promoted By Zergnet


You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!