简体   繁体   中英

Indentation in emacs for html with inline javascript

Here is roughly the kind of code that I have.

<body>
<p>
...
</p>

<script>
function func()
{
...
for(...)
{
...
}
}
</script>

<p> ... </p>

</body>

HTML by itself indents properly, but when I put in the javascript everything screws up.

How do I deal with this?

What I tend to do is have blank lines in between my script tags and then switch over to javascript mode. The html would look like this with the blank line padding

<script type="text/javascript">

   //some javascript

</script>

That seems to allow correct coloring and indenting. I also like to use js3-mode personally as it adds a bit more functionality than emacs' default javascript styling.

You could try one of the multiple modes:

Their goal is to have more than one mode at the same time in the same buffer, specially html and javascript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM