Skip to content

Instantly share code, notes, and snippets.

@protke
protke / tidy_xml_lint.py
Last active December 26, 2015 18:19
Sublime Text 3 Xml Prettifier Plugin, modified for W7. Created by André Bergonse http://www.bergspot.com/blog/2012/05/formatting-xml-in-sublime-text-2-xmllint/
import sublime, sublime_plugin, subprocess
class TidyXmlLintCommand(sublime_plugin.TextCommand):
def run(self, edit):
command = "xmllint -format -encode utf-8 -"
# help from http://www.sublimetext.com/forum/viewtopic.php?f=2&p=12451
# discussion on http://www.bergspot.com/blog/2012/05/formatting-xml-in-sublime-text-2-xmllint/
if self.view.sel()[0].empty():
xmlRegion = sublime.Region(0, self.view.size())