Microsoft KB Archive/178995

From BetaArchive Wiki

Article ID: 178995

Article Last Modified on 6/1/2005



APPLIES TO

  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 4.1 Subscription
  • Microsoft Visual C++ 4.2 Enterprise Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 4.2 Professional Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++ 6.0 Standard Edition



This article was previously published under Q178995

SYMPTOMS

AppWizard and ClassWizard always generate code indented with tabs, regardless of the "Insert Spaces" setting.

RESOLUTION

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:

  1. Select the line(s) containing the undesired tab characters. To select the entire document, click Select All on the Edit menu.
  2. 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:

  1. Determine your tab expansion setting. Click Options on the Tools menu, then click Tabs on the dialog box. Note the setting labeled Tab size.
  2. Select the line(s) containing the undesired tab characters. To remove tabs from the entire document, see step 4.
  3. 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.
  4. In the Replace in section, select either Selection or Whole file. Click OK. Leading and full-width tabs are now replaced with spaces.
  5. 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.


STATUS

This behavior is by design.

MORE INFORMATION

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

  1. Start Visual C++ 5.0.
  2. Click Options on the Tools menu and choose the Tabs section.
  3. Select Insert Spaces. Save the setting by clicking OK.
  4. Create a new project with any of the AppWizards, and open one or more of its files.
  5. 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.


Keywords: kbtshoot kbbug kbfix kbide kbwizard kbcodegen KB178995