This article was previously published under Q178995
This article has been archived. It is offered "as is" and will no longer be updated.
AppWizard and ClassWizard always generate code indented with tabs, regardless of the "Insert Spaces" setting.
Visual C++ 5.0 and 6.0
To remove all undesired tab characters from text displayed in Visual C++ Developer Studio, use the Untabify feature. To "untabify" a set of lines:
Select the line(s) containing the undesired tab characters. To select the entire document, click Select All on the Edit menu.
Click Advanced on the Edit menu, then click Untabify Selection. Spaces replace tab characters. The selected text's visible formatting does not change. All tab characters are correctly replaced by an appropriate number of spaces.
Visual C++ 4.x
To remove undesired tab characters from text displayed in Visual C++ versions earlier than 5.0, use the Replace feature. Follow these steps:
Determine your tab expansion setting. Click Options on the Tools menu, then click Tabs on the dialog box. Note the setting labeled Tab size.
Select the line(s) containing the undesired tab characters. To remove tabs from the entire document, see step 4.
Click Replace on the Edit menu. In the Find what field, type a number of spaces corresponding to the "Tab size" setting. In the Replace with field, type in the same number of spaces.
In the Replace in section, select either Selection or Whole file. Click OK. Leading and full-width tabs are now replaced with spaces.
To remove tabs whose effective widths do not correspond to the Tab size setting (tabs between text), repeat replacing as in steps 3 and 4 but with one less space each time in the Find what and Replace with fields. After replacing all single spaces with single spaces, there will be no remaining tabs in the selection.
This behavior is by design.
Visual C++ Developer Studio offers options to control how the editor processes tab keystrokes. If the Insert Spaces option is selected for the current file type, the editor embeds spaces instead of tab characters into source code whenever the user presses the TAB key.
Some earlier text editors and utility programs automatically expand tabs to a fixed setting, which the user cannot configure (usually eight characters). The text formatting that they display will not properly represent code written with tab expansion set to a different value (four is the default in Developer Studio). For this and other reasons, some users may prefer to have their code formatted with spaces only.
However, AppWizard and ClassWizard always generate code indented with tabs, regardless of the Insert Spaces setting. This behavior may annoy those users who prefer spaces.
Steps to reproduce the behavior
Start Visual C++ 5.0.
Click Options on the Tools menu and choose the Tabs section.
Select Insert Spaces. Save the setting by clicking OK.
Create a new project with any of the AppWizards, and open one or more of its files.
Click Advanced on the Edit menu, then click View Whitespace (not available in VC++ 4.x). The caret symbol (^) will appear where tab characters exist. Verify that indented lines contain tab characters.