如何更正IntelliJ中的缩进 [英] How to correct indentation in IntelliJ

查看:836
本文介绍了如何更正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 + 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.

您可以自定义代码在<$ c下自动格式化的设置$ c>文件→设置编辑代码样式

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天全站免登陆