如何在 IntelliJ 中纠正缩进 [英] How to correct indentation in IntelliJ
问题描述
如何在 IntelliJ 中自动(而非手动)更正缩进?
How can indentation be automatically (not manually) corrected in IntelliJ?
在 Eclipse 中,可以只突出显示需要缩进的代码,右键单击,然后选择 Source
> Correct indentation
.
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?
推荐答案
Code
→ Reformat Code...
(默认 Ctrl + Alt + L) 用于整个文件或 Code
→ Auto-Indent Lines
(默认 Ctrl + Alt + 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.
您可以在 File
→ Settings
→ Editor
→ Code Style下自定义代码如何自动格式化的设置代码>.
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屋!