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