When editing HTML in emacs, is there a way to automatically pretty-format a blob of markup, changing something like this:
<table> <tr> <td>blah</td></tr></table>
…into this:
<table> <tr> <td> blah </td> </tr> </table>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By default, when you visit a
.htmlfile in Emacs (22 or 23), it will put you inhtml-mode. That is probably not what you want. You probably wantnxml-mode, which is seriously fancy.nxml-modeseems to only come with Emacs 23, although you can download it for earlier versions of emacs from the nXML web site. There is also a Debian and Ubuntu package namednxml-mode. You can enternxml-modewith:You can view nxml mode documentation with:
All that being said, you will probably have to use something like Tidy to re-format your xhtml example.
nxml-modewill get you fromto
but I don’t see a more general facility to do line breaks on certain xml tags as you want. Note that
C-jwill insert a new line with proper indentation, so you may be able to do a quick macro or hack up adefunthat will do your tables.