Idea2020版本设置XML文件代码自动缩进 格式化

使用Idea给项目的pom.xml添加依赖或配置xml时,发现在xml里使用代码补全或者粘贴代码时,xml里代码没有自动缩进,并且使用Alt+Shift+L也没有格式化成功

  • 代码补全
<dependencies>
		<dependency>
<groupId></groupId>
<artifactId></artifactId>
</dependency>
  • 粘贴代码
<dependencies>
		<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-devtools</artifactId>
</dependency>

之前也看了很多别人的解决方法,但是并没有解决问题,经过自己的琢磨后成功解决(可能是版本或者其他的原因)我的idea2020版本格式正常了

1.Setting --> Edior --> Code Style --> XML

点开之后,点击Other选项,找到下面的Keep white spaces

 我的默认是勾选的,别人是勾选格式就正常了,但是我是不勾选才正常,你可以试试看看效果

  • 代码补全
	<dependencies>
		<dependency>
			<groupId></groupId>
			<artifactId></artifactId>
		</dependency>
  • 粘贴代码
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
		</dependency>

2.Setting --> Edior --> General --> Smart Keys

如果还是没有效果可以试试这个,我用的是Indent each line(缩进每行),还不行试试另外几个选项

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值