在Eclipse中缩进<head></head>标签

21

当我按下Ctrl+Shift+F时,我希望Eclipse(Kepler)可以缩进<head>...</head>中的HTML标签。

目前的情况是:

<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
function func() {
console.log("Hello world");
}
</script>
</head>
<body>
<p onclick="func()">Some text</p>
</body>
</html>

当我按下快捷键时,它变成了这样。

<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
    function func() {
        console.log("Hello world");
    }
</script>
</head>
<body>
  <p onclick="func()">Some text</p>
</body>
</html>

我需要<head>...</head>中的所有内容都缩进,并且还要缩进<html>...</html>中的所有标记。

最好的方式是这样的:

function func() {
  console.log("Hello world");
}
<html>

<head>
  <title>Insert title here</title>
  <script type="text/javascript">
    /* function */
  </script>
</head>

<body>
  <p onclick="func()">Some text</p>
</body>

</html>


以下链接似乎有你要找的内容: https://dev59.com/GWMm5IYBdhLWcg3wFL04 - sobz
使用 vscode 吧 :D - Tiago Coelho
1个回答

1
您可以尝试前往: 窗口 > 首选项 > Web > HTML文件 > 编辑器。 在内联字段中添加/删除您想要缩进的内容。从我看到的来看,它不包括head标签,因此请尝试将其添加到列表中。

无意义的答案,因为列表中是否有头部(默认)并不会改变缩进的方式。 - maxxyme
3
缩进在上述代码中正确地工作了。不要说毫无意义的答案,提供另一个解决方案。 - Anokim
不幸的是,这并没有产生OP所要求的格式。似乎没有办法使用Eclipse Kepler回答这个问题。 - JonathanDavidArndt

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接