Is there a way to format code in TextWrangler?
I'm using TextWr开发者_如何学JAVAangler on Mac OS X to do some web development. Is there a way to auto format code?
Yes, there is a possibility but not a simple one. Using Text Filters, if you can find a filter your choice you put it into Library/Application Support/TextWrangler/Text Filters
and reach it from Text/Apply Text Filter
menu.
This is how you do it for XML: http://magp.ie/2010/02/15/format-xml-with-textwrangler/
and for PHP: http://wizguild.com/textwrangler_phptidy_filter/
Create a new file -> Tidy XML.sh
Copy and Paste this lines below:
#!/bin/sh
XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 -
Save on Desktop
Open Finder and GO to folder -> ~/Library/Application Support/TextWrangler/Text Filters
Move your Tidy XML.sh from desktop to Text Filters.
Open TextWrangler and beautifier your xml file.
精彩评论