Search code examples
sublimetextprettifysublimetext2

Sublime Text 2 Code Formatting


First let me say I come from a Microsoft background and Visual Studio is my bread and butter. It has a command (keybind is arbitrary) that auto-formats any code syntax. The same command works in HTML, CSS, Javascript, C#, etc.

I have tried plugins for ST2 and so far I've found most don't work on a Windows box and if they do, it's for a very specific purpose like just Javascript.

I have tried (and opened Issues where appropriate):

https://github.com/victorporof/Sublime-HTMLPrettify

https://github.com/jdc0589/JsFormat (this one actually works)

https://github.com/welovewordpress/SublimeHtmlTidy

Have any Windows users of ST2 found anything that works to format CSS/HTML/Javascript, preferably in one shot?

Edit: Since this question is getting lots of views with no activity, I'll say that I am still looking for a plugin that can format various script types within the same command.

October 2013 Still haven't found anything that covers JS+CSS+HTML well however I have settled on JsFormat as by far the most effective and bug free with the least amount of configuration for just JavaScript.


Solution

  • I can't speak for the 2nd or 3rd, but if you install Node first, Sublime-HTMLPrettify works pretty well. You have to setup your own key shortcut once it is installed. One thing I noticed on Windows, you may need to edit your path for Node in the %PATH% variable if it is already long (I think the limit is 1024 for the %PATH% variable, and anything after that is ignored.)

    There is a Windows bug, but in the issues there is a fix for it. You'll need to edit the HTMLPrettify.py file - https://github.com/victorporof/Sublime-HTMLPrettify/issues/12