xml - 在 Eclipse 中格式化 XML 代码

当我在 Eclipse 中编写 .xml 文件时,我经常不得不手动缩进代码。例如

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />

格式化后是这个样子。

<?xml version="1.0" encoding="utf-8"?>
   <LinearLayout   
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:background="@color/background"
      android:layout_height="fill_parent"   
      android:layout_width="fill_parent" />

如何自动化?我在 Eclipse 中找不到 XML 格式设置。

最佳答案

Ctrl+Shift+F

会为你做的,你可以在里面配置

Window -> Preferences -> XML -> Xml Files -> Editor

https://stackoverflow.com/questions/4527474/

相关文章:

php - 如何从 PHP 中的日期时间获取 AM/PM

angularjs - 删除 AngularJS 货币过滤器小数/美分

c++ - 如何使用 ostream 在 c++ 中将 unsigned char 打印为十六进制?

intellij-idea - 如何在 WebStorm 中自动格式化代码?

visual-studio - 如何在 Visual Studio (Express) 2008 中

c++ - 我应该在我的 C++ 代码中使用 printf 吗?

java - 如何将 SimpleDateFormat 与日历一起使用?

c# - 如何使 Visual Studio 不将 { 放在新行上?

visual-studio-2010 - 我可以让 Visual Studio 将花括号与 if 语

.net - .NET 中是否有一种简单的方法来获取数字的 "st"、 "nd"、 "rd"和 "t