如何更正IntelliJ中的缩进 [英] How to correct indentation in IntelliJ
问题描述
如何在IntelliJ中自动(非手动)更正缩进?
How can indentation be automatically (not manually) corrected in IntelliJ?
在Eclipse中,可以只突出显示需要缩进,右键单击的代码,以及选择来源
> 正确缩进
。
In Eclipse, it's possible to just highlight the code that needs indenting, right-click, and select Source
> Correct indentation
.
有没有在IntelliJ中执行相同操作的方法?
Is there any method for doing the same thing in IntelliJ?
推荐答案
代码
→为整个文件重新格式化代码...
(默认 Ctrl + Alt + L )或代码
→自动缩进行
(默认 Ctrl + Alt 当前行或选择的kbd> + I 。
Code
→ Reformat Code...
(default Ctrl + Alt + L) for the whole file or Code
→ Auto-Indent Lines
(default Ctrl + Alt + I) for the current line or selection.
您可以自定义代码在<$ c下自动格式化的设置$ c>文件→设置
→编辑
→代码样式
。
You can customise the settings for how code is auto-formatted under File
→ Settings
→ Editor
→ Code Style
.
为确保评论也缩进到与代码相同的级别,您可以只需按以下步骤操作:
To ensure comments are also indented to the same level as the code, you can simply do as follows:
(JavaScript示例)
这篇关于如何更正IntelliJ中的缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!