Java Reference
In-Depth Information
This feature isn't limited to Java files. IDEA can also insert comments into
the predefined supported file types like JSP , HTML , XML , and so on. Auto-
commenting is even available when you're editing an arbitrary file type for
which you have specified the line- and block-level comment delimiters,
described in more detail in chapter 12.
The Code | Comment Line and Code | Comment block actions work with cus-
tom file types as well as IDEA 's built in file types in version 5.0.
3.6.4
Reformatting code
You can reformat your code to use your current code style selection at any time by
selecting the To o l s | R e f o r m a t C o d e ( Ctrl+Alt+L ) command from the main
menu. A dialog box will appear, as shown in figure 3.16, in which you can change
the scope of the reformatting to include the file, your selected text, or all the files
in the directory. When you're ready to go, click the Run button. IDEA will use all
of your code style options to layout the spacing, indentation, and other proper-
ties. This makes it possible to switch code styles in the middle of a project and to
reformat the entire source tree. Refer to chapter 12 for information about config-
uring your code style settings.
The Reformat Code action was moved from the Tools menu to the Code menu in
version 5.0.
If you select the Optimize imports option, IDEA also rewrites and rearranges
your import statements. It uses your code style settings to determine exactly how
you prefer them, but in general it removes unused imports, decides whether to
Figure 3.16
The reformatting feature can keep your
whole project strictly adhered to a specific
code style.
 
 
 
 
Search WWH ::




Custom Search