Sublime Forum

TagIndent

#1

EDIT : Use Tag Package instead.

I was unable to find a solution to format simple bits of HTML/XML/RDF/XUL ( some invalid ), then I created “TagIndent” plugin:

Usage
There is a context menu item called “Indent Tags on Selection”
There is also a Main menuitem: Edit -> Tag -> “Indent Tags on Selection”.
There is also a command called “Indent Tags on Selection”.

Aims
Aims to add and/or apply correct indentation to little portions of HTML or XML, not to complete documents.

Information
It takes the starting “indentation level” from the first line of each selection and sums tabs as needed.
On empty tags, and on tags with less than 40 characters, it writes the tag in one line.
Short-cut is “ctrl+shift+h”

Source / Installation
github.com/SublimeText/TagIndent

Update:

  • Repository moved to SublimeText Organization at github.
  • Support self closing tags.
0 Likes

TextMate-style "Indent Selection"?
Dreamweaver like apply source formatting
#2

Handy :smile:

I often review and clean up code from our front-end designer who, for some reason, doesn’t bother with well-formed code like adhering to a common standard of tabs vs spaces between documents and sometimes even varies from 4 spaces to 2 spaces to tabs in a single document!

0 Likes

#3

Very nice!

One problem is it seems to move my end of div comments around though. This…

</div><!-- .overlay -->

Becomes this…

<!-- .overlay --></div>
0 Likes

#4

I can’t repro with that little information…

I know this:

<div></div><!-- end -->

Become this:

[code]

[/code] But not what you described, a move of a tag inside another.
0 Likes

#5

hi tito, if there’s a php on top of <!doctype, it indents the doctype,

it also indents these:

[code]

[/code]

to this:

<html class="no-js ie6 oldie" lang="en"> <![endif]--><!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]--><!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"><!--<![endif]-->

0 Likes

#6

Hi, sorry is not perfect.

The idea is to apply source formatting on easy portions of HTML documents, not entire documents.

Also if someone want to re-write or add a better implementation of “tag indent” please do it on “tag” package, then we don’t end with 5 packages with does the same thing.

0 Likes

#7

Could you add this to package manager? :smile: That would be awesome
Take a look at how! wbond.net/sublime_packages/packa … developers

0 Likes

#8

This package is from some time ago mixed with “Tag” package. Available from “Package Control”
github.com/SublimeText/Tag
Regards,

0 Likes