如何在Eclipse中自动格式化代码?

本文翻译自:How to auto-format code in Eclipse?

你如何在Eclipse中自动格式化代码?


#1楼

参考:https://stackoom.com/question/13gc2/如何在Eclipse中自动格式化代码


#2楼

On Windows : Ctrl + Shift + F 在Windows上Ctrl + Shift + F.

On Mac : + + F 在Mac上 + + F.

(Alternatively you can press Format in Main Menu > Source) (或者您可以按主菜单>来源中的Format


#3楼

Another option is to go to Window->Preferences->Java->Editor->SaveActions and check the Format source code option. 另一种选择是转到Window-> Preferences-> Java-> Editor-> SaveActions并检查Format source code选项。 Then your source code will be formatted truly automatically each time you save it. 然后,每次保存时,您的源代码都将自动格式化。


#4楼

按: Ctrl + A或突出显示要缩进的代码部分,然后按ctrl + i


#5楼

CTRL + SHIFT + F将自动格式化您的代码(无论是突出显示还是非突出显示)。


#6楼

Windows -> Preferences -> Java -> Editor -> save actions -> Format source code -> Format Edited lines (or) format all lines. Windows - >首选项 - > Java - >编辑器 - >保存操作 - >格式化源代码 - >格式编辑行(或)格式化所有行。

Some time when you work as a team, lead don't want you to format all lines of the code in a source file (Huge track changes will be there on commit). 有些时候,当你作为一个团队工作时,领导者不希望你在源文件中格式化代码的所有行(巨大的轨道更改将在提交时出现)。 So, select 'Format Edited lines'. 因此,选择“格式编辑的行”。 This will edit and format only the lines you modified. 这将仅编辑和格式化您修改的行。

Gubs 广东商学院

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值