Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

indenting tags within <head></head> in eclipse

Tags:

I need Eclipse(Kepler) to indent html tags within <head>...</head> when I hit Ctrl+Shift+F

Currently, this:

<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>

becomes this when I hit the key combination.

<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>

I need everything within <head>...</head> to be indented and also all the tags within <html>...</html>.

Ideally this way:

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>
like image 938
Plakhoy Avatar asked Nov 26 '14 10:11

Plakhoy


People also ask

Should the head tag be indented?

The contents of those tags should always be indented for clean markup, so that the nesting structure is clear to the reader.


1 Answers

You could try to go to: Window > Preferences > Web > HTML Files > Editors.

Add/Remove what you want to indent from the inline field. From what I saw it doesn't include the head tag, so try adding in the list.

like image 52
Anokim Avatar answered Nov 15 '22 13:11

Anokim