Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Tabs and spaces in code files


1. Tabs and spaces in code files
When writing code, tabs and spaces can create issues. A tab character moves the character position to the next tab stop, which could be 3, 5, 8, or some other setting.

To see the Notepad++ tab settings, select "Settings", "Preferences", "Tab Settings". Note: It is best not to check "Replace by space" since that can cause issues with indentation of code (though some programmers like that option).

When you put tab characters within text in double quotes, it may look fine in the editor, but when expanded on the command line when the program is run, the spacing may not be as desired.

2. Character codes

3. Non-breaking space
The non-breaking space character is code #160. When copy-pasting code from, say, the Internet, strange characters like this one can end up in your code file - with various results that may not be desired.

4. Recommended style rule
Recommended style rule so this does not happen:

5. Notepad++
Many editors provide a way to see tabs and spaces.

In Notepad++, do the following. You will now be able to see where tab characters are within your code. To turn it off, use the same method to uncheck that option.

6. Without the setting
NPP not showing tabs and spacesHere is an image of a code file without the setting. One cannot see tabs and spaces.

7. With the setting
NPP showing tabs and spacesHere is an image of a code file with the setting. One can see visual indicators of tabs and spaces.

8. End of page

9. Multiple choice questions for this page