Sublime Forum

Indent XML

#1

Hi all,
today made small but useful plugin which allow turn

<?xml version="1.0" encoding="UTF-8"?><root><node1>data here</node1><node2 attr="222"><node3/></node2></root>
to formatted XML

<?xml version="1.0" ?> <root> <node1> data here </node1> <node2 attr="222"> <node3/> </node2> </root>

You could get it here: github.com/alek-sys/sublimetext_indentxml
Any comments are welcome!
P.S. Hope that this is not a one of the standard features which I just don’t know about :smile:

1 Like

Expand XML (or other code)
Formatting XML?
Expand XML (or other code)
#2

Thanks! Works a treat!

0 Likes

#3

Doesn’t work with Cyrillic characters in text. File encoding is UTF-8 without BOM.

0 Likes

#4

Fixed, check github.com/alek-sys/sublimetext_indentxml for update

0 Likes

#5

Good news, everyone!
“Indent XML” was added to Package Control (wbond.net/sublime_packages/package_control) default repository.
So to install Indent XML just run “Package control: Install package” (of course, having Package Control already installed) command in Sublime Text.

0 Likes

#6

I am trying to get this plug-in to work on my Mac, but unsuccessful so far. I installed it using the Package Control, which lists the plug-in as installed, but I don’t know how to run it… :smile: Anyone succeeded in installing this on a Mac?

0 Likes

#7

Same here, I could not make it work on mac os x :frowning:

0 Likes

#8

Great!

hoping it can Indent HTML

0 Likes

#9

Hi all,
everyone having problem with Indent XML are welcome to help resolve it here github.com/alek-sys/sublimetext … l/issues/1
I’m looking for Mac now :smile: (already about to buy it :wink: ), hope to get it fixed asap.

Alex.

0 Likes

#10

[quote=“leecade”]Great!
hoping it can Indent HTML[/quote]

Not quite sure, because it uses the xml.minidom parser and not every HTML is valid XML. I will think is it possible to use TidyHTML or any 3rd party tools.

Alex.

0 Likes

#11

Okey, just got MacOS virtual machine and installed sublime + indent XML via “package control”.

It seems it works fine. Just to clarify - recently one good man added keyboard shortcut for Mac so try first update package (if it wasn’t happened automatically). Second, key combination is super+k (hold super!) super+f. So first press super then k then f. This should work. Or open console and type view.run_command(“indentxml”)

Regards, Alexey.

0 Likes

#12

Hi, just tried to use Ident XML on Sublime Text 2 beta 2165 on Ubuntu Oneiric Ocelot 64 bit. It installs just fine, but when I try to use it I get this error in the console:

Traceback (most recent call last): File "./sublime_plugin.py", line 351, in run_ return self.run(edit) File "./indentxml.py", line 32, in run File "./indentxml.py", line 48, in indentxml File ".\xml\dom\minidom.py", line 1927, in parseString File ".\xml\dom\expatbuilder.py", line 32, in <module> File ".\xml\parsers\expat.py", line 4, in <module> ImportError: No module named pyexpat
Any ideas? The module is installed just fine in my regular Python (2.6 and 2.7) install.

0 Likes

#13

This fixed the problem for me…

$ sudo apt-get install python2.6
$ ln -s /usr/lib/python2.6 [Sublime Text dir]/lib/

Found this tip on GitHub somewhere.

0 Likes

#14

Traceback (most recent call last):
File “./sublime_plugin.py”, line 362, in run_
File “./indentxml.py”, line 51, in run
File “./indentxml.py”, line 100, in indent
ImportError: No module named pyexpat

in Ubuntu 15.04

I’ve tried using $ sudo ln -s /usr/lib/python2.7 /opt/sublime_text_2/lib/

So in /opt/sublime_text_2/lib I have a python2.7 file that ought to link to /usr/lib/python2.7, but the error persists

Am I doing something wrong?

0 Likes

#15

Hi, I’ve installed your plug-in on sublime text 3 throught the package control and it works like a charm.

My question is: how can I use the keyboard shortcut keys to auto intent all the xml ?

0 Likes

#16

This works for me (SublimeText Build 3114 and OS X 10.11.5) but when there is an XML error in the file I get a message like “xml.parsers.expat.ExpatError: duplicate attribute: line 1, column 14669” and then have to load the file in Safari to find in which line and column the error is. It would be helpful if Indent XML reported the actual line and column number of the error.

0 Likes

#17

I did everything mentioned, and still not working, not showing, nothing…i deleted and installed the sublime text like 3 times, and nothing.

When i am looking for “indent xml” or “indent” or “xml” there is nothing like indent xml, and i have the god damn file in every folder of the application, i made the tutorial 3 times, still not showing or working ctrl + k just delete everything…

0 Likes

#18

Thanks for point this out. For future, to save some time, please follow the installation instructions from [GitHub page] (https://github.com/alek-sys/sublimetext_indentxml). The recommended approach is to use [PackageControl] (https://packagecontrol.io) manager.

0 Likes

#19

I installed this plugin. When I select XML text and then choose Selected - Format - Indent XML, nothing happens!

0 Likes

#20

it is possible you are running into this issue?

if not, maybe log a new one with exact reproduction steps

0 Likes