File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1616 { "command" : " convert_camel_dash" , "caption" : " Convert camelCase <-> Dash" },
1717 { "command" : " convert_pascal_underscores" , "caption" : " Convert PascalCase <-> Underscores" },
1818 { "caption" : " -" },
19+ { "command" : " string_utilities_expand_string" , "caption" : " Expand Selection To Whole String" },
1920 { "command" : " convert_single_quotes_to_double" , "caption" : " Convert Single Quotes To Double" },
2021 { "command" : " convert_double_quotes_to_single" , "caption" : " Convert Double Quotes To Single" },
2122 { "command" : " url_encode" , "caption" : " Encode as URL Notation" },
Original file line number Diff line number Diff line change 11[
2+ {
3+ "caption" : " String Utilities: Expand Selection to Whole String" ,
4+ "command" : " string_utilities_expand_string"
5+ },
26 {
37 "caption" : " String Utilities: Convert Tabs to Spaces" ,
48 "command" : " convert_tabs_to_spaces"
Original file line number Diff line number Diff line change 2424 def unichr (c ):
2525 return chr (c )
2626
27+ class StringUtilitiesExpandStringCommand (sublime_plugin .TextCommand ):
28+ """If the region is contained in a string scope, expands the region to
29+ the whole string. If the region is not contained in a string scope, this
30+ command does nothing. It is applied to all regions in the current
31+ selection."""
32+
33+ def run (self , edit ):
34+ for region in self .view .sel ():
35+ self ._run (edit , region )
36+
37+ def _run (self , edit , region ):
38+ if (not self .view .match_selector (region .a , "string" ) or
39+ not self .view .match_selector (region .b , "string" )):
40+ return
41+ selector = "string punctuation.definition.string"
42+ p = region .begin ()
43+ while not self .view .match_selector (p , selector ):
44+ p = self .view .find_by_class (p , False , sublime .CLASS_PUNCTUATION_START )
45+ q = region .end ()
46+ while not self .view .match_selector (q , selector ):
47+ # sublime.CLASS_PUNCTUATION_END is broken
48+ # this works too
49+ q = self .view .find_by_class (q , True , sublime .CLASS_PUNCTUATION_START )
50+ self .view .sel ().add (sublime .Region (p , q + 1 ))
2751
2852class ConvertTabsToSpacesCommand (sublime_plugin .TextCommand ):
2953 #Convert Tabs To Spaces
You can’t perform that action at this time.
0 commit comments