17

I'm finding myself pasting in a tonne of code that is minified, i,e all on one line.

Rather than scanning through it manually and adding in linebreaks to make it readable, is there an option in Sublime to do it, or a plugin?

For example, I have this (although much longer):

<html><head><title>some title</title></head><body><div><span>some content</span></div></body></html>

And I want to end up with this, without spending half an hour pressing enter on my keyboard:

<html>
  <head>
    <title>some title</title>
  </head>
  <body>
    <div>
      <span>some content</span>
    </div>
  </body>
</html>
totallyNotLizards
  • 8,489
  • 9
  • 51
  • 85

2 Answers2

15

If you have the Package Manager installed in you can install the Tidy HTML package.

garyh
  • 2,782
  • 1
  • 26
  • 28
  • I installed tidyHtml, but unsure what command to use. reindenting still doesnt seem to do anything. in the meanitime, highlighting a close angle bracket and putting a cursor at each one (ctrl+cmd+g) and adding a line break seems to work best. – totallyNotLizards Nov 19 '12 at 14:24
  • 1
    With the HTML file open, Ctrl+Shift+P, then start to type Tidy HTML. If it was installed correctly it should be the only menu option remaining. Click on that. – garyh Nov 19 '12 at 15:03
15

Tidy HTML for Sublime Text 2

HTML-CSS-JS Prettify for Sublime Text 3

Fatih Hayrioğlu
  • 3,458
  • 1
  • 26
  • 46
  • 3
    Thanks! HTML-CSS-JS Prettify worked great for me. Note that HTML-CSS-JS Prettify requires node.js to be installed. – MiniRagnarok Dec 03 '14 at 14:05
  • Thank you! Perfectly prettified a minified script without any error using Sublime-HTMLPrettify. – Anirban Jun 23 '16 at 08:31