Possible Duplicate:
What mode do people use when using Emacs to edit web pages that contain CSS, javascript, and HTML?
Using emacs built-in JavaScript mode or SteveY's js2 mode, I get great syntax coloring of JavaScript in a *.js file. Is there a way to get good syntax coloring of the bits of JavaScript inside a *.html file? (maybe a better html mode than what comes with the editor by default, or some way to select a region and colorize it as *.js?). Thanks!
5.43 How do I turn on syntax highlighting? font-lock-mode is the standard way to have Emacs perform syntax highlighting in the current buffer. It is enabled by default. With font-lock-mode turned on, different types of text will appear in different colors.
Using web-mode-el: This way of configuring emacs is simplest and easiest. We can use major mode “web-mode. el” for this kind of usage where we want to edit HTML files that have JavaScript, CSS, JAVA(JSP), PHP.
web-mode can let you edit HTML documents embedding CSS / JavaScript and Server blocks
Yes, this turns out to be a duplicate of the link above.
Short answer: One can use nxhtml with it's multiple major modes (MuMaMo), but I couldn't get that to work for me. One can search the emacs wiki for mumamo to see several multiple mode alternative packages, but none of them did it for me. One can also use indirect buffers and put them into different modes than eachother. I also tried changing the major mode of my html file to js, but it had a hard time finding the js inside the script tags.
Finally, a co-worker suggested narrowing the buffer and putting it into Javascript mode, and that worked well for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With