How Many Spaces In A Tab?


In Microsoft Word you can control whether or not you want to see the white space characters in your document. This helps to check you haven’t incorrectly inserted a tab where a space should have gone and vice versa.

Generally a tab is the same width as 4 to 5 spaces provided the font being used equally sizes each character. For example, the Courier font’s tab equals 5 spaces, whereas the Arial font is 11 spaces to each tab when the font size for both is set to 12.

Number of spaces per tab in Courier & Arial fonts

What happens when you increase the font size to 36 for each? The Courier font reduces down to 2 spaces, and the Arial font reduces down to 4 spaces:

As the font size increases, the number of spaces per tab decreases

To see how many spaces per tab for the font being used in Microsoft Word (Mac version), simply go to your Preferences pane and on the View and select the following items:

Show tab and white space characters in Word document

Programming

In coding there are certain languages such as Python where the indentation is very important, and even if Python isn’t used it helps for readability if your code has indentation.

Sublime Text 3

If you are using some of the popular text editors today, such as Sublime Text, you have a variety of options in the menu panel’s View options to set the number of spaces each tab character will contain, and whether you want the tab character to be converted to spaces.

Here are the options available for setting your tab spacing using the menu:

Sublime Text tab settings – set your tab width to whatever you like, default is 4

Why convert the tab character to spaces?

I have found it helpful to set this option whenever I’m copying and pasting code from my editor to the terminal. I’ve found the tab character can make the pasted code in the terminal look rather weird, and therefore just prefer to convert those tab characters to spaces.

How to see white space characters in Sublime Text?

To see white space characters in your Sublime Text editor you will need to add the following line to your user preferences:

"draw_white_space": "all"

PyCharm

Another popular editor I use is PyCharm, and like Sublime Text you can also view whitespace and set the tab space length.

To enable viewing of the white space character open up the Preferences pane and navigate to Editor > General > Appearance and within this window you should see the option to Show whitespaces:

Show whitespaces in PyCharm

To control the tab width navigate to Editor > Code Style > Python and within this window make sure you’re looking at the Tabs and indents window which will look as follows:

Set the tab size and select whether or not to use the tab character

Summary

Coding software such as Sublime Text and PyCharm set the default tab width to 4 spaces and provide the opportunity for the user to convert those tab characters to spaces. Microsoft Word though does not afford this luxury as you are bound to the type of font used as we have shown between the two popular fonts Courier and Arial, and the size of those fonts.

All programs do provide the ability to view your white space characters making it easier to see the type of white space entered.

Ryan

Author of scripteverything.com, Ryan has been dabbling in code since the late '90s when he cut his teeth by exploring VBA in Excel when trying to do something more. Having his eyes opened with the potential of automating repetitive tasks, he expanded to Python and then moved over to scripting languages such as HTML, CSS, Javascript and PHP. When he is not behind a screen, Ryan enjoys a good bush walk with the family during the cooler months, and going with them to the beach during the warmer months.

Recent Posts