forked from jdavisclark/JsFormat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Davis Clark
committed
Sep 1, 2011
0 parents
commit bc24c44
Showing
7 changed files
with
1,123 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
*.pyc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "keys": ["ctrl+alt+f"], "command": "js_format"} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "keys": ["ctrl+alt+f"], "command": "js_format"} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "keys": ["ctrl+alt+f"], "command": "js_format"} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "caption": "Format: Javascript", "command": "js_format" } | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import sublime, sublime_plugin, jsbeautifier | ||
|
||
class JsFormatCommand(sublime_plugin.TextCommand): | ||
def run(self, edit): | ||
opts = jsbeautifier.default_options(); | ||
opts.indent_char = " " | ||
opts.indent_size = 4 | ||
opts.max_preserve_newlines = 3 | ||
selection = self.view.sel()[0] | ||
replaceRegion = selection if len(selection) > 0 else sublime.Region(0, self.view.size()) | ||
res = jsbeautifier.beautify(self.view.substr(replaceRegion), opts) | ||
prePos = self.view.sel()[0] | ||
self.view.replace(edit, replaceRegion, res) | ||
self.view.show_at_center(prePos.begin()) | ||
|
Oops, something went wrong.