Regex - Format with tabs and alphabetical

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-06-15T19:08:29Z Indexed on 2010/06/15 19:12 UTC
Read the original article Hit count: 189

Filed under:
|
|
|

Is it possible to use regex to turn this

<site-ui:header title="error" backURL="javascript:history.go(-1);" />

into this

<site-ui:header 
  backURL="javascript:history.go(-1);" 
  title="error" 
/>

Basically, my goal is to format this xml so that the fields are in alphabetical order (e.g. backURL comes before title), and each field should be tabbed two spaces.

If this can be done, any pointers would be really helpful! Even more helpful is an exact regex for vim.

© Stack Overflow or respective owner

Related posts about Xml

Related posts about regex