如何在 IntelliJ 中纠正缩进 [英] How to correct indentation in IntelliJ

查看:37
本文介绍了如何在 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?

推荐答案

CodeReformat Code... (默认 Ctrl + Alt + L) 用于整个文件或 CodeAuto-Indent Lines(默认 Ctrl + Alt + I) 用于当前行或选择.

CodeReformat Code... (default Ctrl + Alt + L) for the whole file or CodeAuto-Indent Lines (default Ctrl + Alt + I) for the current line or selection.

您可以在 FileSettingsEditorCode Style.

You can customise the settings for how code is auto-formatted under FileSettingsEditorCode Style.

为了确保注释也缩进到与代码相同的级别,您可以简单地执行以下操作:

To ensure comments are also indented to the same level as the code, you can simply do as follows:

(JavaScript 示例)

这篇关于如何在 IntelliJ 中纠正缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆