Forked from coldnebo/Default (Linux).sublime-keymap
Last active
December 13, 2015 18:58
-
-
Save laurent22/4958842 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" }, | |
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" } | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin, subprocess | |
class PrettifyJsonCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
# requires rubygems json: 'gem install json' | |
command = '/local/rvm/bin/rvm exec prettify_json.rb' | |
# help from http://www.sublimetext.com/forum/viewtopic.php?f=2&p=12451 | |
p = subprocess.Popen(command, bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) | |
result, err = p.communicate(self.view.substr(self.view.sel()[0]).encode('utf-8')) | |
self.view.replace(edit, self.view.sel()[0], result.decode('utf-8')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin, subprocess | |
class TidyXmlCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
command = 'tidy -xml -i -utf8 -w -q' | |
# help from http://www.sublimetext.com/forum/viewtopic.php?f=2&p=12451 | |
p = subprocess.Popen(command, bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) | |
result, err = p.communicate(self.view.substr(self.view.sel()[0]).encode('utf-8')) | |
if err != "": | |
self.view.set_status('tidyxml', "tidyxml: "+err) | |
sublime.set_timeout(self.clear,10000) | |
else: | |
self.view.replace(edit, self.view.sel()[0], result.decode('utf-8')) | |
def clear(self): | |
self.view.erase_status('tidyxml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment