Pages - Menu

Sunday, February 19, 2012

How to Convert Tabs to Spaces


With Microsoft Word
1. Log in to you user account in Windows XP/Vista.
2. Click the 'Start' button in the lower left corner of the screen.
3. Click 'All Programs' and then open the folder 'Microsoft Office.' Click 'Microsoft Word' to launch the program.
4. Press 'Ctrl-O' and browse your computer to open a file in Microsoft Word.
5. 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.'
6. Type '^t' in the field 'Find what.' (Note: To type the symbol '^' press 'Shift+6.') Type a space in the field 'Replace with.'
7. 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.
8. Press 'Ctrl-S' to save the modified Word document.
In Linux
9. Log in to your user account in Linux. Right-click on Desktop and click 'Open (or New) terminal' in the pop-up menu.
10. Type 'cd your_folder' in the terminal window and press 'Enter' to navigate to the folder that contains a text file.
11. 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.
12. 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.
13. Press 'Esc' on the keyboard and type ':wq' to save the file and quit the vi editor.