Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
div
classnavigation
HTML Table
width100%
Table Row (tr)
Table Cell (td)
width33%
Align
alignleft
Previous
span
classsep
|
span
classtext
Inspections
Table Cell (td)
width33%
Align
aligncenter
Top
span
classsep
|
span
classtext
Quick Start
Table Cell (td)
width33%
Align
alignright
Next
span
classsep
|
span
classtext
Intentions

...

Wiki Markup
{div:class=navigation}
{table:width=100%}
{tr}
{td:width=33%}{align:left}[Previous|Inspections] {span:class=sep}\| {span}{span:class=text}Inspections{span}{align}{td}
{td:width=33%}{align:center}[Top|Quick Start] {span:class=sep}\| {span}{span:class=text}Quick Start{span}{align} {td}
{td:width=33%}{align:right}[Next|Intentions] {span:class=sep}\| {span}{span:class=text}Intentions{span}{align} {td}
{tr}
{table}
{div}

Wiki Markup
{redirect:https://www.jetbrains.com/idea/help/code-style-and-formatting.html

...

|delay

...

=0}

Info
iconfalse

Code style defines how code looks in terms of indents, spacing, wrapping, blank lines treatment, statements order, etc.

...

IntelliJ IDEA automatically applies code style you've configured as you edit, and in most cases you don’t need to call

Reformat Code
span
classshortcut
Wiki Markup
{span:class=shortcut}Reformat Code{span}
action explicitly. However, you can do so anytime either for current file, selected piece of code, or even an entire directory by simply pressing
span
classshortcut
Alt
+
span
classshortcut
Ctrl
+
span
classshortcut
L
(
span
classshortcut
Alt
+
span
classshortcut
Cmd
+ L
span
classshortcut
Wiki Markup
{span:class=shortcut}Alt{span}
+
Wiki Markup
{span:class=shortcut}Ctrl{span}
+
Wiki Markup
{span:class=shortcut}L{span}
(
Wiki Markup
{span:class=shortcut}Alt{span}
+
Wiki Markup
{span:class=shortcut}Cmd{span}
+
Wiki Markup
{span:class=shortcut}L{span}
for Mac.)

When you want to apply

Reformat Code
span
classshortcut
Wiki Markup
{span:class=shortcut}Reformat Code{span}
to an entire directory, use the same shortcut in the Project Tool Window
span
classshortcut
Wiki Markup
{span:class=shortcut}Project Tool Window{span}
.

2. Auto-indent lines

Another useful action is

span
classshortcut
Wiki Markup
{span:class=shortcut}Auto-Indent Lines{span}
, which helps you to fix line indentation. This action sometimes is a better option than Reformat Code
span
classshortcut
Wiki Markup
{span:class=shortcut}Reformat Code{span}
, because it does not require you to select anything. Just press
span
classshortcut
Alt
+
span
classshortcut
Ctrl
+
span
classshortcut
I
(
span
classshortcut
Alt
+
span
classshortcut
Cmd
+ I
span
classshortcut
Wiki Markup
{span:class=shortcut}Alt{span}
+
Wiki Markup
{span:class=shortcut}Ctrl{span}
+
Wiki Markup
{span:class=shortcut}I{span}
(
Wiki Markup
{span:class=shortcut}Alt{span}
+
Wiki Markup
{span:class=shortcut}Cmd{span}
+
Wiki Markup
{span:class=shortcut}I{span}
for Mac), and it will quickly fix indents for the current line.

...

IntelliJ IDEA lets you configure code style settings for each of the supported languages either at project or IDE level via

span
classshortcut
Settings
Code Style
span
classshortcut
Wiki Markup
{span:class=shortcut}Settings{span}
Wiki Markup
{span:class=shortcut}Code Style{span}
.

When you choose

Project
span
classshortcut
Wiki Markup
{span:class=shortcut}Project{span}
scheme in settings, you can share your code style with other team members via version control.

...

Last, but not least of the settings worth your attention is

Use tab character
span
classshortcut
Wiki Markup
{span:class=shortcut}Use tab character{span}
. By default this setting is off and IntelliJ IDEA uses regular spaces for indents instead of tabs. If you have files with lots of indents, you may want to optimize their size by selecting this option.

div
classnavigation
HTML Table
width100%
Table Row (tr)
Table Cell (td)
width33%
Align
alignleft
Previous
span
classsep
|
span
classtext
Inspections
Table Cell (td)
width33%
Align
aligncenter
Top
span
classsep
|
span
classtext
Quick Start
Table Cell (td)
width33%
Align
alignright
Next
span
classsep
|
span
classtext
Intentions Wiki Markup
{div:class=navigation}
{table:width=100%}
{tr}
{td:width=33%}{align:left}[Previous|Inspections] {span:class=sep}\| {span}{span:class=text}Inspections{span}{align}{td}
{td:width=33%}{align:center}[Top|Quick Start] {span:class=sep}\| {span}{span:class=text}Quick Start{span}{align} {td}
{td:width=33%}{align:right}[Next|Intentions] {span:class=sep}\| {span}{span:class=text}Intentions{span}{align} {td}
{tr}
{table}
{div}