Sublime Forum

Dreamweaver like apply source formatting

#1

In DreamWeaver, use the Apply Source Formatting command in the Command menu, I tried duplicating this in Textmate, its a pain using HTML Tidy it doesn’t always work when I use html tidy, just wondering if there’s some plugin out there that can do this?

I tend to edit a lot of code from others, and I have to run through apply source formatting first in dreamweaver so that I can use expand to tag or code folding features of sublime, Because when tags aren’t aligned in indention, expand to tag sometimes doesn’t work.

Any help is deeply appreciated.

0 Likes

#2

well thing is the tidy version is helluva slow in textmate… That’s why I love sublime text 2 so much, its blazing fast, lightning fast, I don’t want to bash textmate so much but everything is slow there. And yes, it does give me dodgy results, its broken a lot of code, for me, and just decided not to use it. Dreamweaver’s implementation is much more reliable. I mainly use it to fix inherited code from other developers. WIth one pass of apply source formatting in Dreamweaver, their code becomes readable all of a sudden :smile:. Only gripes is that you have to apply per file, you can’t apply it per folder in Dreamweaver.

also I do hope tidy supports html 5, since the one dreamweaver has is very useful in html and css, I say its very customizable up to the tag level and it just works even on html5 syntax, I think mainly because it just checks the opening closing tags, something to do with logic, I’m not saying the logic behind in tidy is slow, but I think the one dreamweaver made is more efficient. Imagine Dreamweaver CS5, faster than TextMate? (with regards to apply source formatting) so its must be their implementation that’s why its fast.

To be honest that’s the only thing I keep Dreamweaver for = apply source formatting, and its superior find and replace text. Better than any editor I’ve used.

Might you direct me on a tidy plugin for sublime text 2, that supports html 5? Thanks for the reply :smile:

0 Likes

#3

I’m looking for something lean, take a look at this:

gist.github.com/1138554

See how lean the code is but this is for JSON and XML, I do hope there’s one for html. And thanks for the link, how do you use this python lib? Sorry I just jumped in Sublime, so I don’t know much, but I’m willing to learn :smile:

0 Likes

#4

+1, Please, tell us, how we can install this plugin? HTML Tidy
It is used for auto-formatting HTML source, or i’m noob, and don’t understand this subj? :smiley:

0 Likes

#5

hey @sublimator,
any chance you can teach us how to use it that python library you linked as a sublime plugin? it would be awesome if it can appear on the command palette :smile:

0 Likes

#6

Take a look to TagIndent
Very similar to the dreamweaver function I used so much… Let me know with an example if you found some problem.

0 Likes

#7

Hi,

I created a formatter plugin for my needs, it’s only going to work with linux for now.
It’s currently supporting php, html, css, js, python. But you can easily add more languages.
I’m still not sure which formatter I should use for Java, C++ and C, I tried AStyle, but it didn’t really work.
With PHP it is using php_beautifier, with html it is using tidy, with css it is using a php-script, with python it is using a python script. You can find all the formatter executables in the folder bin/

Just add a keybinding to “codeformatter” Command and the selected code will be formatted with by using the keybinding.

Download SublimeCodeFormatter

Greets.

P.S. The code is not the best, it is my first python code… :smile:

0 Likes

#8

@tito
very fast plugin, I like, it would be more awesome if you can specify tags that won’t insert enter, like ,

etc, depending upon your preference, but very well written plugin. Any chance you know a css reformatter plugin for sublime?

0 Likes

#9

I wasn’t able to get this plugin to work. I put it in the packages dir and added a keyboard shortcut in Default.sublime-keymap: { “keys”: “ctrl+alt+z”], “command”: “codeformatter” } which does not clash with any other shortcut.

I load up an HTML file, screw it up and hit the key sequence and… nothing.

What am I doing wrong?

0 Likes

#10

Use tag package for HTML

0 Likes

#11

@nobleach
Sorry, lost track of the thread, you have to first select what you want to format and then type your keybinding.

0 Likes