It was asked some time ago, but anyway, there is a good package, for many languages, here: https://sublime.wbond.net/packages/CodeFormatter
Answer from Surt on Stack OverflowVideos
- CodeFormatter: (abandoned, throws errors)
- JSPrettier - doesn't support php
- Others I've tried just either don't work or can't find them in package control?
Do any of you have a php code beautifier plugin that works? Preferably an option to beautify on save. Thank you!
Thanks a lot for your answer, but i found a nice, built in approach of sublime text. Just select everything (CTRL + a (Windows) or CMD + a (Mac) and click this in the menu
Edit โ Line โ Reindent
maybe this helps also others
EDIT(2017): You can also use key combination (without need for mouse)
CTRL + SHIFT + P (Windows)
CMD + SHIFT + P (Mac)
then type 'Reindent' and select the fist option 'Indentation: Reindent Lines'
Check out HTML-CSS-JS Prettify. It requires nodejs be installed and in your PATH, but once you get that set up properly it works great. Make sure you read all of the docs, though.