94

I have been used Ctrl+Shift+F to correct indentation but I heard there is another shortcut to do that: Ctrl+I

According a reference found in google, Ctrl+Shift+F is Reformat and Ctrl+I is Correct indentation.

Is there any difference between them? or between Reformat and Correct indentation?

Jainendra
  • 24,713
  • 30
  • 122
  • 169
RENO
  • 1,225
  • 1
  • 10
  • 10

4 Answers4

124

If you press CTRL + I it will just format tabs/whitespaces in code and pressing CTRL + SHIFT + F format all code that is format tabs/whitespaces and also divide code lines in a way that it is visible without horizontal scroll.

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
  • 3
    Ctrl + I works only if those tabs/whitespaces are at the beginning. It doesn't work if you have something like `int i = _____5;` ( _ = empty space ). Only Ctrl + Shift + F will convert this line to `int i = 5;`. – ROMANIA_engineer Oct 26 '14 at 07:54
13

Ctrl+Shift+F formats the selected line(s) or the whole source code if you haven't selected any line(s) as per the formatter specified in your Eclipse, while Ctrl+I gives proper indent to the selected line(s) or the current line if you haven't selected any line(s).

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
RAS
  • 8,100
  • 16
  • 64
  • 86
  • 2
    i think this is the correct answer because this is best used when you specify a formatter in eclipse. – Lou Morda Oct 27 '14 at 04:39
6

Reformat affects the whole source code and may rebreak your lines, while Correct Indentation only affects the whitespace at the beginning of the lines.

Roland Illig
  • 40,703
  • 10
  • 88
  • 121
1

Ctrl+Shift+F formats the selected line(s) or the whole source code if you haven't selected any line(s) as per the format specified in your Eclipse, while Ctrl+I gives proper indent to the selected line(s) or the current line if you haven't selected any line(s). try this. or more precisely

The Ant editor that ships with Eclipse can be used to reformat

XML/XHTML/HTML code (with a few configuration options in Window > Preferences > Ant > Editor).

You can right-click a file then

Open With... > Other... > Internal Editors > Ant Editor

Or add a file association between .html (or .xhtml) and that editor with

Window > Preferences > General > Editors > File Associations

Once open in the editor, hit ESC then CTRL-F to reformat.

Community
  • 1
  • 1