Forked from coldnebo/Default (Linux).sublime-keymap
Last active
December 13, 2015 18:58
Revisions
-
laurent22 revised this gist
Feb 15, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ class TidyXmlCommand(sublime_plugin.TextCommand): def run(self, edit): self.view.run_command('select_all') command = 'tidy -xml -i -utf8 -w -q' # help from http://www.sublimetext.com/forum/viewtopic.php?f=2&p=12451 -
coldnebo revised this gist
Nov 3, 2011 . 2 changed files with 20 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,27 @@ class PrettifyJsonCommand(sublime_plugin.TextCommand): def run(self, edit): command = 'python -mjson.tool' # 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')) # gave up trying this approach: result always has '\n' strings in it that refuse to render #result = json.dumps( self.view.substr(self.view.sel()[0]), indent=2) # http://code.activestate.com/recipes/65211/ seems to say that Python "ruins" non-raw strings by # actually placing '\','n' in the friggin string unless it's marked 'raw'? Is that true? Shouldn't a string be a string # and the raw/not raw output be a function of the runtime? Why does "print" have some magic to reescape these strings and # yet there are no other buffer objects that seem to do it (aka StringIO or BytesIO). if result != "": self.view.replace(edit, self.view.sel()[0], result.decode('utf-8')) sublime.set_timeout(self.clear,0) else: self.view.set_status('tidyjson', "tidyjson: "+err) sublime.set_timeout(self.clear,10000) def clear(self): self.view.erase_status('tidyjson') 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ def run(self, edit): sublime.set_timeout(self.clear,10000) else: self.view.replace(edit, self.view.sel()[0], result.decode('utf-8')) sublime.set_timeout(self.clear,0) def clear(self): -
coldnebo revised this gist
Nov 3, 2011 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,4 +8,12 @@ def run(self, edit): 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') -
coldnebo revised this gist
Aug 10, 2011 . 2 changed files with 23 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ 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')) self.view.replace(edit, self.view.sel()[0], result.decode('utf-8')) -
coldnebo created this gist
Aug 10, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ [ { "keys": ["ctrl+shift+x"], "command": "tidy_xml" }, { "keys": ["ctrl+shift+j"], "command": "prettify_json" } ]