import sublime, sublime_plugin, re

class ExpandRegionCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    region = self.view.sel()[0]
    string = self.view.substr(sublime.Region(0, self.view.size()))
    start = region.begin()
    end = region.end()

    if self.expand_to_word(string, start, end) is None:
      if self.expand_to_quotes(string, start, end) is None:
        print 'none'
  
  def expand_to_word(self, string, startIndex, endIndex):
    wordRe = re.compile("^[a-zA-Z0-9_]*$");

    search = True;
    searchIndex = startIndex;
    while search:
      char = string[searchIndex:searchIndex+1]
      if wordRe.match(char) is None:
        newStartIndex = searchIndex + 1
        search = False
      else:
        searchIndex -= 1

    search = True;
    searchIndex = endIndex;
    while search:
      char = string[searchIndex:searchIndex+1]
      if wordRe.match(char) is None:
        newEndIndex = searchIndex
        search = False
      else:
        searchIndex += 1


    if startIndex == newStartIndex and endIndex == newEndIndex:
      return None
    else:
      self.view.sel().add(sublime.Region(newStartIndex, newEndIndex))
      return True

  def expand_to_quotes(self, string, startIndex, endIndex):
    quotesRe = re.compile(r'([\'"])(?:\1|.*?[^\\]\1)')

    for match in re.finditer(quotesRe, string):
      start = match.start()
      end = match.end()

      if end < startIndex:
        continue

      if(startIndex >= start + 1 and endIndex <= end - 1):
        if(startIndex == start +1 and endIndex == end - 1):
          self.view.sel().add(sublime.Region(start, end))
        else:
          self.view.sel().add(sublime.Region(start + 1, end - 1))
        break
@@ -365,32 +365,97 @@
 , end) is None:%0A
+        if self.expand_to_symbols(string, start, end) is None:%0A  
         print 'n
@@ -1775,8 +1775,1426 @@
    break
+%0A%0A  def expand_to_symbols(self, string, startIndex, endIndex):%0A    quotesRe = re.compile(r'(%5B%5C(%5C%5B%5C%7B%5D)')%0A%0A    search = True;%0A    searchIndex = startIndex - 1;%0A    while search:%0A      char = string%5BsearchIndex:searchIndex+1%5D%0A      result = quotesRe.match(char)%0A      if result:%0A        symbolToFind = result.group()%0A        newStartIndex = searchIndex + 1%0A        search = False%0A      else:%0A        searchIndex -= 1%0A%0A    counterparts = %7B%0A      %22(%22:%22)%22,%0A      %22%7B%22:%22%7D%22,%0A      %22%5B%22:%22%5D%22,%0A      %22)%22:%22(%22,%0A      %22%7D%22:%22%7B%22,%0A      %22%5D%22:%22%5B%22%0A    %7D%0A%0A    symbolPairRe = re.compile(r'(%5B'+re.escape(symbolToFind)+re.escape(counterparts%5BsymbolToFind%5D)+'%5D)')%0A%0A    symbolStack = %5BsymbolToFind%5D%0A%0A    search = True;%0A    searchIndex = endIndex;%0A    while search:%0A      char = string%5BsearchIndex:searchIndex+1%5D%0A      result = symbolPairRe.match(char)%0A      if result:%0A        symbol = result.group()%0A%0A        if symbolStack%5Blen(symbolStack) - 1%5D == counterparts%5Bsymbol%5D:%0A          symbolStack.pop()%0A        else:%0A          symbolStack.append(symbol)%0A%0A        if len(symbolStack) == 0:%0A          newEndIndex = searchIndex;%0A          break%0A%0A      if searchIndex == len(string):%0A        search = False%0A%0A      searchIndex += 1%0A%0A    if(startIndex == newStartIndex and endIndex == newEndIndex):%0A      self.view.sel().add(sublime.Region(newStartIndex - 1, newEndIndex + 1))%0A    else:%0A      self.view.sel().add(sublime.Region(newStartIndex, newEndIndex))

Add expand to symbols (heavy wip)