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

Commit 1fccdb0

Browse files
authored
Merge pull request #186 from mtxr/feature/format_all_file
Add new command to Format All File
2 parents a0bff7f + e1d1c43 commit 1fccdb0

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

Default (Linux).sublime-keymap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{ "keys": ["ctrl+e", "ctrl+b"], "command": "st_format" },
1111
{ "keys": ["ctrl+e", "ctrl+q"], "command": "st_save_query" },
1212
{ "keys": ["ctrl+e", "ctrl+r"], "command": "st_remove_saved_query" },
13-
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries"},
14-
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}}
13+
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries", "args": {"mode" : "run"}},
14+
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}},
15+
{ "keys": ["ctrl+e", "ctrl+i"], "command": "st_list_queries", "args": {"mode" : "insert"}}
1516
]

Default (OSX).sublime-keymap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{ "keys": ["ctrl+e", "ctrl+b"], "command": "st_format" },
1111
{ "keys": ["ctrl+e", "ctrl+q"], "command": "st_save_query" },
1212
{ "keys": ["ctrl+e", "ctrl+r"], "command": "st_remove_saved_query" },
13-
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries"},
14-
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}}
13+
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries", "args": {"mode" : "run"}},
14+
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}},
15+
{ "keys": ["ctrl+e", "ctrl+i"], "command": "st_list_queries", "args": {"mode" : "insert"}}
1516
]

Default (Windows).sublime-keymap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{ "keys": ["ctrl+e", "ctrl+b"], "command": "st_format" },
1111
{ "keys": ["ctrl+e", "ctrl+q"], "command": "st_save_query" },
1212
{ "keys": ["ctrl+e", "ctrl+r"], "command": "st_remove_saved_query" },
13-
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries"},
13+
{ "keys": ["ctrl+e", "ctrl+l"], "command": "st_list_queries", "args": {"mode" : "run"}},
1414
{ "keys": ["ctrl+e", "ctrl+o"], "command": "st_list_queries", "args": {"mode" : "open"}},
1515
{ "keys": ["ctrl+e", "ctrl+i"], "command": "st_list_queries", "args": {"mode" : "insert"}}
1616
]

Default.sublime-commands

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
"caption": "ST: History",
2020
"command": "st_history"
2121
},
22-
{
23-
"caption": "ST: Type Query",
24-
"command": "st_query"
25-
},
2622
{
2723
"caption": "ST: Show Table Records",
2824
"command": "st_show_records"
@@ -59,9 +55,13 @@
5955
"args" : {"mode": "insert"}
6056
},
6157
{
62-
"caption": "ST: Format Current SQL File",
58+
"caption": "ST: Format SQL",
6359
"command": "st_format"
6460
},
61+
{
62+
"caption": "ST: Format SQL All File",
63+
"command": "st_format_all"
64+
},
6565
{
6666
"caption": "ST: About",
6767
"command": "st_version"

SQLTools.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,14 @@ def run(edit):
588588
View().replace(edit, region, Utils.formatSql(textToFormat, settings.get('format', {})))
589589

590590

591+
class StFormatAll(TextCommand):
592+
@staticmethod
593+
def run(edit):
594+
region = sublime.Region(0, View().size())
595+
textToFormat = View().substr(region)
596+
View().replace(edit, region, Utils.formatSql(textToFormat, settings.get('format', {})))
597+
598+
591599
class StVersion(WindowCommand):
592600
@staticmethod
593601
def run():

0 commit comments

Comments
 (0)