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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6068009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:11:04  来源:igfitidea点击:

Difference between Ctrl+Shift+F and Ctrl+I in Eclipse

eclipseauto-indent

提问by RENO

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

我已经习惯Ctrl+ Shift+ F,以正确的缩进,但我听说还有另外一个快捷方式做到这一点:Ctrl+I

According a referencefound in google, Ctrl+Shift+Fis Reformat and Ctrl+Iis Correct indentation.

根据一个参考在谷歌发现, Ctrl+ Shift+F是重新格式化和 Ctrl+I是正确的缩进。

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

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

回答by Harry Joy

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

如果您按CTRL+I它只会格式化代码中的制表符/空格,然后按CTRL+ SHIFT+F格式化所有格式化制表符/空格的代码,并以无需水平滚动即可看到的方式划分代码行。

回答by RAS

Ctrl+Shift+Fformats 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+Igives proper indent to the selected line(s) or the current line if you haven't selected any line(s).

Ctrl+ Shift+F如果您没有按照 Eclipse 中指定的格式化程序选择任何行,则格式化所选行或整个源代码,而Ctrl+I对所选行或当前行进行适当缩进如果您没有选择任何行。

回答by Roland Illig

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

重新格式化会影响整个源代码并可能会重新换行,而正确缩进只影响行首的空格。

回答by Zhoha Damani

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

如果您没有按照 Eclipse 中指定的格式选择任何行,则 Ctrl+Shift+F 格式化所选行或整个源代码,而 Ctrl+I 对所选行进行适当缩进) 或当前行(如果您尚未选择任何行)。尝试这个。或更准确地说

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

Eclipse 附带的 Ant 编辑器可用于重新格式化

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.

XML/XHTML/HTML 代码(在“窗口”>“首选项”>“Ant”>“编辑器”中有几个配置选项)。

您可以右键单击一个文件,然后

打开方式... > 其他... > 内部编辑器 > Ant 编辑器

或者在 .html(或 .xhtml)和该编辑器之间添加文件关联

窗口 > 首选项 > 常规 > 编辑器 > 文件关联

在编辑器中打开后,按 ESC 然后按 CTRL-F 重新格式化。