# Editor Options: Formatting

This tab enables you to define the formatting style you want to apply to your source files in the editor. The settings in this panel apply globally. Some options apply to all languages while others are language-specific.

This panel has the following elements.

Element | Description
--- | ---
Language | Select a language from the dropdown list modify the formatting settings for the selected language. The languages that are available in the dropdown list will depend upon the languages that are enabled in your IDE installation. All Languages refers to all languages except C++.
Category | Select a category from the dropdown list. If you selected All Languages, the only Category of options is Tabs and Indents. The categories that are available in the dropdown list depend upon the language that is selected.
Tabs and Indents | Select this category to specify the values for tabs and indentations in the editor.
Use All Languages Settings | When selected the source editor uses the values for tabs and spaces that are specified for All Languages. This option is only available when a specific language is selected.
Expand Tabs to Spaces | When selected, inserts spaces when the Tab key is typed. When unselected, typing the Tab key inserts the tab character (\t) into the file if possible. It also replaces preceding spaces with the tab character if possible. The Source Editor calculates where to place tab characters based on the value of the Tab Size property. If Expand Tabs to Spaces is unselected and the Number of Spaces per Indent is different than the Tab Size property, the indentation created by typing the Tab key is made up of a combination of spaces and tab characters. It is easiest to predict the location of tab characters if you set Number of Spaces per Indent to an even multiple or divisor of Tab Size. Important: This feature does not convert existing tabs to spaces. Only tabs that you add after you enable this option are converted.
Number of Spaces per Indent | Number of spaces per indentation level for sub-elements, new lines inside brackets, etc.
Tab size | See the description of Expand Tabs to Spaces, above.
Right Margin | Specifies the position of the vertical red line that indicates the right margin. The default is 80 characters.
Line Wrap | Whether lines are wrapped when they are longer than the width of the Editor window (no relationship to right margin). You can select from the following options.
Off | No line wrapping (default).
After words | Words are not broken by line wrapping.
Anywhere | Lines are broken in the middle of words by line wrapping.
Alignment | Select this category to specify which elements should be aligned after a line break.
New Lines | The IDE breaks lines before any elements you select here.
Group Multiline Alignment | Aligns the selected character horizontally across all lines in a group. A group is defined as a number of lines that contain the same type of assignments. The group can be terminated by an empty line, a line with only a comment, a different expression, or the end of a block.
Assignment | Affects position of the equal sign character = in a group of lines with assignments. When you set this to 'on', the assignment char '=' is aligned after the longest identifier in a group. This formatting option works for variable assignments, field initializations, and constants.
Array Initializer | Affects position of the initializer characters => in a group of lines.
Multiline Alignment | Use if you set lines to wrap automatically at an element and you want that element to be aligned vertically. Requires that wrapping is enabled for the element before you select the element in this dialog.
Braces | Select where to place the braces for each type of statement listed in this dialog. Use the Format function (Alt+Shift+F) to apply the Braces settings to a PHP document.
Blank Lines | Improves readability by setting off sections of code that are logically related according to the specified options. Select the number of blank lines to place in the listed positions. In the PHP editor, you also have the option to Group Fields Without PHP Doc. This is selected by default. When you select this option, there are no blank lines between fields that do not have PHPDoc documentation.
Spaces | In this panel, set where the IDE automatically puts whitespaces. Due to the large number of possible places to put whitespaces, the places to put whitespaces are displayed in a tree of categories. Expand a tree node to see the places under a category, or collapse a node to hide the places under a category.
Wrapping | In this panel set the rules for the IDE to wrap lines automatically. The panel lists the possible elements before which the IDE wraps lines. For each element you can have the IDE never wrap lines, always wrap lines, or wrap lines if the statement is long (wider than the Editor window). You can also have the IDE automatically wrap lines after opening and before closing block braces, and between statements that are typed on the same line. Both of these options are enabled by default.
Comments | In this panel you can specify formatting options for general code comments and Javadoc
Enable Comments Formatting | When selected you can select specific formatting style options for implementing general code and Javadoc comments.
Imports | Use this panel to specify options that control the formatting of import statements that are generated by the IDE.
Use Single Class Imports | Select to import only a particular class from a package during import optimization and code generation.
Import Inner Classes | When selected, the IDE creates imports for the inner classes referenced in your code.
Class Count to Use Star Import | Number of classes to be imported from a single package until all statements importing a single class are substituted with a statement importing an entire package.
Members Count To Use Static Star Import | Number of static import statements that are allowed for static members of the same type before type is used.
Packages To Use Star Import | Specify a list of packages to be imported completely. Click Add to specify the package name or Remove to delete the currently selected entry from the list.
Use Package Imports | Select to import packages during import optimization and code generation.
Use Fully Qualified Names | Select to use the fully qualified name of the class during import optimization and code generation.
Import Layout | Specify how import statements should be organized in your code.
Separate Static Imports | When selected, static imports are kept in a separate section. Click Add to add a package name to the list. Click Move Up and Move Down to position certain entries first, or last, or one after another in the list. Click Remove to delete the currently selected entry from the list.
Separate Groups | When selected, imported classes are grouped as per their packages and sorted alphabetically within a package.
Naming | Use this panel to specify the prefixes and suffixes that are used in refactoring, code generation and code completion for fields, parameters and local variables.
Ordering | In this panel you can set the rules that control the order in which members in a file are displayed in the editor. The Preview pane enables you to view how the members are displayed based on the sort order.
Members Sort Order | Define the order in which the IDE inserts the generated code elements. Use the Move Up and Move Down buttons to place the elements in the desired order.
Sort Members by Visibility | When selected, the IDE sorts generated class members by the visibility modifier. Use the Move Up and Move Down buttons to place the following elements in the desired order.
Keep Getters and Setters Together | When selected, the getter and setter methods are grouped in pairs.
Sort Members in Groups Alphabetically | When selected, the members of a group are listed in alphabetical order.
Sort uses dependencies | Is automatically selected when Sort Members by Visibility is chosen. When selected, dependencies between fields and initializers are respected to prevent compile errors and semantic changes.
Insertion Point | Use the dropdown list to select where the generated elements are placed in the code.

The Preview pane displays how the applied changes will appear in the Source Editor.

Related Topics

Developing Applications with NetBeans IDE,

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.