在创建了许多文件后,我将Eclipse配置更改为use spaces instead of tabs。它起作用:我写的新东西使用空格。但是我昨天写的文件当然还有标签。我想将从标签转换为空格。
对于Java文件很简单:打开文件,按CTRL + a,按CTRL + i,完成。
但如何对XML文件执行 ?与Java不同,使用XML文件CTRL + a / CTRL + i不仅可以转换标签,还可以尝试“改进格式化”,这会破坏事物:
初始代码:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans>
<bean id="webscript.helloworld.get"
class="com.example.HelloWorldWebScript"
parent="webscript">
</bean>
</beans>
CTRL + a / CTRL + i(或CTRL + SHIFT + f)后:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<beans>
<bean id="webscript.helloworld.get" class="com.example.HelloWorldWebScript"
parent="webscript">
</bean>
</beans>
问题:对于Eclipse中的XML文件,如何将制表符转换为空格而不进行其他更改?
答案 0 :(得分:1)
好吧,如果您是手动操作,并且不想要自动脚本,只需在XML文件中写一个标签,然后复制它,然后按ctrl + f&gt;更换,粘贴标签以找到替换的内容和空间,然后只需更换全部。如果您不想用脚本替换它,那就是这样。
答案 1 :(得分:1)
Search
- &gt; Search...
(或 Ctrl + H ) - &gt; File Search
,
检查Regular expression
,
将\t
设为Containing text:
,
将*.xml
设为File name patterns
,
点击Replace...
,设置
(根据需要添加空格) - &gt;
OK
。
完成。请享用。
答案 2 :(得分:1)