Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #186 from mtxr/feature/format_all_file
Browse files Browse the repository at this point in the history
Add new command to Format All File
  • Loading branch information
tkopets authored Jan 29, 2018
2 parents a0bff7f + e1d1c43 commit 1fccdb0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{ "keys": ["ctrl+e", "ctrl+b"], "command": "st_format" },
{ "keys": ["ctrl+e", "ctrl+q"], "command": "st_save_query" },
{ "keys": ["ctrl+e", "ctrl+r"], "command": "st_remove_saved_query" },
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries"},
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}}
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries", "args": {"mode" : "run"}},
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}},
{ "keys": ["ctrl+e", "ctrl+i"], "command": "st_list_queries", "args": {"mode" : "insert"}}
]
5 changes: 3 additions & 2 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{ "keys": ["ctrl+e", "ctrl+b"], "command": "st_format" },
{ "keys": ["ctrl+e", "ctrl+q"], "command": "st_save_query" },
{ "keys": ["ctrl+e", "ctrl+r"], "command": "st_remove_saved_query" },
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries"},
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}}
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries", "args": {"mode" : "run"}},
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}},
{ "keys": ["ctrl+e", "ctrl+i"], "command": "st_list_queries", "args": {"mode" : "insert"}}
]
2 changes: 1 addition & 1 deletion Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{ "keys": ["ctrl+e", "ctrl+b"], "command": "st_format" },
{ "keys": ["ctrl+e", "ctrl+q"], "command": "st_save_query" },
{ "keys": ["ctrl+e", "ctrl+r"], "command": "st_remove_saved_query" },
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries"},
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries", "args": {"mode" : "run"}},
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}},
{ "keys": ["ctrl+e", "ctrl+i"], "command": "st_list_queries", "args": {"mode" : "insert"}}
]
10 changes: 5 additions & 5 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"caption": "ST: History",
"command": "st_history"
},
{
"caption": "ST: Type Query",
"command": "st_query"
},
{
"caption": "ST: Show Table Records",
"command": "st_show_records"
Expand Down Expand Up @@ -59,9 +55,13 @@
"args" : {"mode": "insert"}
},
{
"caption": "ST: Format Current SQL File",
"caption": "ST: Format SQL",
"command": "st_format"
},
{
"caption": "ST: Format SQL All File",
"command": "st_format_all"
},
{
"caption": "ST: About",
"command": "st_version"
Expand Down
8 changes: 8 additions & 0 deletions SQLTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,14 @@ def run(edit):
View().replace(edit, region, Utils.formatSql(textToFormat, settings.get('format', {})))


class StFormatAll(TextCommand):
@staticmethod
def run(edit):
region = sublime.Region(0, View().size())
textToFormat = View().substr(region)
View().replace(edit, region, Utils.formatSql(textToFormat, settings.get('format', {})))


class StVersion(WindowCommand):
@staticmethod
def run():
Expand Down

0 comments on commit 1fccdb0

Please sign in to comment.