first commit of json prettify plugin

This commit is contained in:
Nikolajus 2012-02-03 15:32:42 +01:00
commit 6f5cfc4c4a
7 changed files with 45 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.pyc
*.cache
*.sublime-project

View File

@ -0,0 +1,3 @@
[
{ "keys": ["ctrl+alt+j"], "command": "prettyjson" }
]

View File

@ -0,0 +1,3 @@
[
{ "keys": ["super+ctrl+j"], "command": "prettyjson" }
]

View File

@ -0,0 +1,3 @@
[
{ "keys": ["ctrl+alt+j"], "command": "prettyjson" }
]

15
PrettyJson.py Normal file
View File

@ -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))

13
README.md Normal file
View File

@ -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

5
package-metadata.json Normal file
View File

@ -0,0 +1,5 @@
{
"description": "Prettify JSON plugin for Sublime Text 2",
"url": "https://github.com/dzhibas/SublimePrettyJson",
"version": "1.0.0"
}