Is there a way to format code in TextWrangler?
Asked Answered
B

2

21

I'm using TextWrangler on Mac OS X to do some web development. Is there a way to auto format code?

Bellwort answered 29/9, 2011 at 6:20 Comment(1)
I got tired of scripts/filters for every language in TextWrangler - TextMate does this out of the box so I switched to that.Corsair
S
8

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/

Spiritualty answered 22/10, 2012 at 14:28 Comment(6)
can't find the folder Library/Application Support/TextWrangler on my mac os x 10.8Demulcent
Hey @someone0 - you can create the folder yourself and then just restart the app. OSX is so much harder than Windows...'it just works' is a pile of sh**! It just works if you know bash scripting and UNIX commands. :(Gatlin
@someone0 In the case you can't see the Library folder: The Library folder is really there but hidden. Open your home folder in the Finder, from Go menu choose "Go to Folder..." and enter Library. I add it to the favourites on my systems.Spiritualty
to the gods of notepad++ hear the cry of mac users. We need youVentriculus
@someone0 In the view options for your home directory there is a checkbox to show the Library folder.Good
@sam - Do you know of a Tidy script for Java?Buggs
D
2

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.

Duleba answered 26/4, 2015 at 13:41 Comment(2)
I'm having trouble with this one. It keeps saying there are incomplete tags even though I copied the code straight from the pristine HTML source code produced from the browser's Developer Tools.Chafee
Okay, a little more success adding the --html flag, but all it does is wrap the code in an HTML and BODY tag and it is not indenting or aligning anything. It did warn me about duplicate id tags, which I appreciated, but I was hoping it would, you know, format the text...Chafee

© 2022 - 2024 — McMap. All rights reserved.