Share via


How to: Specify Indenting in the Editor

You can choose from three different styles of text indenting, as well as choose whether the Editor inserts tabs or space characters when indenting text. In addition, you can determine how many spaces represent a single indentation or tab, and adjust indenting manually or apply Smart Indenting to selected blocks of code.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Working with Settings.

To choose an indention style

  1. On the Tools menu, select Options.

  2. In the Text Editor folder, choose the Tabs options in the All Languages subfolder to set this option globally.

    — or —

    Choose the Tabs options in the subfolder for the language in which you are programming.

  3. Under Indenting, select one of the following:

    • None -- The cursor goes to the beginning of the next line.

    • Block -- The cursor aligns the next line with the previous line.

    • Smart -- (Default, when available) The language in which you are programming determines the appropriate indention style to use. For example, when you create a For...Next loop in Visual Basic that includes If or Select Case statements, these statements will be displayed as code blocks indented within the loop, where their own customary internal indentations will be preserved.

  4. Click OK.

To change indent tab settings

  1. On the Tools menu, select Options.

  2. In the Text Editor folder, choose the Tabs options in the All Languages subfolder to set this option globally.

    — or —

    Choose the Tabs options in the subfolder for the language in which you are programming.

  3. To specify that tab characters be used in tab and indent operations, select Keep tabs.

    — or —

    To specify that space characters be used, select Insert spaces.

  4. If you choose to Insert spaces, enter the number of space characters used to represent each tab and indent in Tab and Indent size.

To increase or decrease indenting manually

  1. Select the text you want to indent.

  2. To increase indenting, press the TAB key or select the Indent icon.

    Visual Basic WinApp Project Indent Button

    — or —

    To decrease indenting, press the SHIFT+TAB key combination or select the Unindent icon.

    Text Unindent Button

To apply Smart indenting to selected code

  1. Select the Smart option for Indenting for the language in which you are programming. For detailed instructions, see the procedure "To choose an indention style" earlier in this topic.

  2. Select the text to which you wish to apply Smart indenting.

  3. On the Edit menu, select Advanced and choose Format Selection, or press the key combination CTRL+K, CTRL+F.

    Format Selection applies the smart indenting rules for your development language to the selected text.

To convert tab-length white spaces to tabs, or tabs to white spaces

  1. Select the text you wish to convert.

  2. On the Edit menu, select Advanced.

  3. Choose Tabify Selected Lines to convert tab-length white spaces to tab characters.

    — or —

    Choose Untabify Selected Lines to convert tab characters to tab-length white spaces.

    All of the tabs or white spaces to the left of the first letter, number, or symbol will be converted. Tabs and white space in the middle or end of the line will not be affected.

    Note

    The functionality of these commands depends upon the current settings for tab length in the Tabs, All Languages, Text Editor, Options Dialog Box and in the Tabs options for the language in which you are programming. For example, if the tab length setting is four, Tabify Selected Lines will create a tab for every four contiguous spaces, and Untabify Selected Lines will create four spaces for every tab.

See Also

Concepts

Customizing the Editor

Other Resources

Setting Editor Options

Editing Text, Code, and Markup