WizGuild

TextWrangler PHPTidy filter

I love TextWrangler. Performance of TextWrangler is just incredible compared to the alternatives. Just try to open a few hundred megabytes long XML and do a search and replace. Others will give you the spinning beach-ball for minutes. Its only real weakness is long lines. I miss few key features, though. I’m not a big fan of BBedit, those extra features are not for me, I actually found them very distracting.

Of course, TextWrangler is just a text editor, not an IDE, so cannot give you code completion, nor jump to declaration. But it’s extendible with text filters. Now here, where the magic comes!

As I work with others’ sometimes poorly formatted php codes I need to reformat codes from time to time. Using NetBeans just to copy-paste-reformat-copy-paste is overkill. PHPTidy is a nice tool for reformatting code, but I had to overcome few misfeatures:

  • it works with files (reading from file instead of standard input)
  • there is a non-optional argument “command”, as phptidy has lots of features
  • it does not break lines after semicolons

…so I had to tweak the code a little. I hope you will find it useful.

Just extract the .zip file and put the .php file into your user’s Library/Application Support/TextWrangler/Text Filters folder. If you can’t find Library folder (you have Lion or newer system so it’s hidden) go to your home folder (shift-command-h) then choose Go => Go to Folder… (shift-command-g), type Library and hit enter (or press the Go button). I tend to pull the folder into the Favourites bar after going there once.

Oh, yes, your download link:

PHPTidy text filter for TextWrangler

For XMLTidy I use this shell script:

Comments are closed.