first commit of json prettify plugin
This commit is contained in:
commit
6f5cfc4c4a
|
@ -0,0 +1,3 @@
|
|||
*.pyc
|
||||
*.cache
|
||||
*.sublime-project
|
|
@ -0,0 +1,3 @@
|
|||
[
|
||||
{ "keys": ["ctrl+alt+j"], "command": "prettyjson" }
|
||||
]
|
|
@ -0,0 +1,3 @@
|
|||
[
|
||||
{ "keys": ["super+ctrl+j"], "command": "prettyjson" }
|
||||
]
|
|
@ -0,0 +1,3 @@
|
|||
[
|
||||
{ "keys": ["ctrl+alt+j"], "command": "prettyjson" }
|
||||
]
|
|
@ -0,0 +1,15 @@
|
|||
import sublime
|
||||
import sublime_plugin
|
||||
import json
|
||||
|
||||
|
||||
class PrettyjsonCommand(sublime_plugin.TextCommand):
|
||||
def run(self, edit):
|
||||
for region in self.view.sel():
|
||||
selection = self.view.substr(region)
|
||||
|
||||
try:
|
||||
obj = json.loads(selection)
|
||||
self.view.replace(edit, region, json.dumps(obj, indent=4, ensure_ascii=False, sort_keys=True))
|
||||
except Exception, e:
|
||||
sublime.status_message(str(e))
|
|
@ -0,0 +1,13 @@
|
|||
Prettify JSON plugin for Sublime Text 2
|
||||
|
||||
## Installation
|
||||
Install this repository via [Package Control](http://wbond.net/sublime_packages/package_control)
|
||||
|
||||
## Usage
|
||||
To prettify json, make selection of json and press keys:
|
||||
|
||||
- Linux: `ctrl+shift+j`
|
||||
- Windows: `ctrl+shift+j`
|
||||
- OS X: `super+shift+j`
|
||||
|
||||
If JSON is not valid it will be displayed in status bar of sublime
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"description": "Prettify JSON plugin for Sublime Text 2",
|
||||
"url": "https://github.com/dzhibas/SublimePrettyJson",
|
||||
"version": "1.0.0"
|
||||
}
|
Loading…
Reference in New Issue