Eclipse中Ctrl + Shift + F和Ctrl + I之间的区别

时间:2011-05-20 05:59:44

标签: eclipse auto-indent

我已经使用 Ctrl + Shift + F 来更正缩进但我听说还有另一种快捷方式: CTRL +

根据谷歌发现的reference Ctrl + Shift + F 是重新格式化 和 Ctrl + I 是正确的缩进。

它们之间有什么区别吗?或重新格式化和正确缩进之间?

4 个答案:

答案 0 :(得分:117)

如果按 CTRL + I ,它只会在代码中格式化标签/空格并按 CTRL + SHIFT + F 格式化所有格式制表符/空格的代码,并以不可水平滚动的方式划分代码行。

答案 1 :(得分:12)

Ctrl + Shift + F 格式化选定的行或整个源代码(如果您尚未选择任何行) s)根据Eclipse中指定的格式化程序,而 Ctrl + I 给出所选行或当前行的正确缩进(如果您还没有选择任何行)线(S)。

答案 2 :(得分:6)

重新格式化会影响整个源代码并可能会重新生成您的行,而“正确缩进”只会影响行开头的空格。

答案 3 :(得分: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.