Share via


Options, Text Editor, JavaScript, Formatting

Use the Formatting page of the Options dialog box to set options for formatting code in the Code Editor. To access this page, on the menu bar, choose Tools, Options, and then expand Text Editor, JavaScript, and Formatting.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Settings.

Automatic Formatting

These options determine when formatting occurs in Source view.

Option

Description

Format completed line on Enter

When this option is selected, the Code Editor automatically formats the line when you choose the Enter key.

Format completed statement on ;

When this option is selected, the Code Editor automatically formats the line when you choose the semicolon key.

Format completed block on }

When this option is selected, the Code Editor automatically formats the line when you choose the closing brace key.

Format on paste

When this option is selected, the Code Editor reformats code when you paste it into the editor. The editor uses the currently defined formatting rules. If this option is not selected, the editor uses the original formatting of the pasted-in code.

New Lines

These options determine whether the Code Editor puts an open brace for functions and control blocks on a new line.

Option

Description

Place open brace on new line for functions

When this option is selected, the Code Editor moves the open brace associated with a function to a new line.

Place open brace on new line for control blocks

When this option is selected, the Code Editor moves the open brace associated with a control block (for example, if and while control blocks) to a new line.

Spacing

These options determine how spaces are inserted in Source view.

Option

Description

Insert space after comma delimiter

When this option is selected, the Code Editor adds a space after comma delimiters.

Insert space after semicolon in 'for' statement

When this option is selected, the Code Editor adds a space after each semicolon in the first line of a for loop.

Insert space before and after binary operators

When this option is selected, the Code Editor adds a space before and after binary operators (for example, +, -, &&, ||).

Insert space after keywords in control flow statements

When this option is selected, the Code Editor adds a space after JavaScript keywords in control flow statements.

Insert space after function keyword for anonymous functions.

When this option is selected, the Code Editor adds a space after the function keyword for anonymous functions.

Insert space after opening and before closing non-empty parenthesis

When this option is selected, the Code Editor adds a space after the opening parenthesis and before the closing parenthesis if non-empty characters are present within the parentheses.

See Also

Tasks

How to: Set Editor Tab and Indent Options

Reference

General, Environment, Options Dialog Box