Skip to content
This repository
Browse code

Init

  • Loading branch information...
commit 40addd87fe972d92b1cd2e689eab2be3dba311e8 0 parents
Alexey Nesterov authored
3  Default (Windows).sublime-keymap
... ... @@ -0,0 +1,3 @@
  1 +[
  2 + { "keys": ["ctrl+k", "ctrl+f"], "command": "indentxml" }
  3 +]
8 README
... ... @@ -0,0 +1,8 @@
  1 +To install plugin you need:
  2 +1) Copy indentxml.py to <Sublime Text plugins directory>\Users. If you not sure where is it located start Sublime Text and open Preferences -> Browse packages... In dialog opened you could copy path to plugins directory.
  3 +For Windows 7 it is usually C:\Users\<UserName>\AppData\Roaming\Sublime Text 2\Packages\User
  4 +
  5 +2) Add key binding in Preferences -> Key bindings... like
  6 + { "keys": ["ctrl+k", "ctrl+f"], "command": "indentxml" }
  7 +
  8 +3) Done, now select XML and press Ctrl + K, Ctrl + F
15 indentxml.py
... ... @@ -0,0 +1,15 @@
  1 +import sublime, sublime_plugin
  2 +from xml.dom.minidom import parseString
  3 +
  4 +class IndentxmlCommand(sublime_plugin.TextCommand):
  5 +
  6 + def run(self, edit):
  7 + view = self.view
  8 + for region in view.sel():
  9 + if not region.empty():
  10 + # Get the selected text
  11 + s = view.substr(region)
  12 + # Transform it via rot13
  13 + s = parseString(s).toprettyxml()
  14 + # Replace the selection with transformed text
  15 + view.replace(edit, region, s)

0 comments on commit 40addd8

Please sign in to comment.
Something went wrong with that request. Please try again.