Can emacs re-indent a big blob of HTML for me?

后端 未结 10 1964
生来不讨喜
生来不讨喜 2021-01-29 20:09

When editing HTML in emacs, is there a way to automatically pretty-format a blob of markup, changing something like this:

  
10条回答
  •  清酒与你
    2021-01-29 21:01

    You can pipe a region to xmllint (if you have it) using:

    M-|
    Shell command on region: xmllint --format -
    

    The result will end up in a new buffer.

    I do this with XML, and it works, though I believe xmllint needs certain other options to work with HTML or other not-perfect XML. nxml-mode will tell you if you have a well-formed document.

提交回复
热议问题