Example #1
0
    def run(self, edit):
        new_sels = []
        for s in self.view.sel():
            line = self.view.line(s.b)
            line_str = self.view.substr(line)
            m = match_around(r'[\w\.]+', line_str, s.b - line.begin())
            if m:
                r = sublime.Region(m[0] + line.begin(), m[1] + line.begin())
                s = self.view.substr(r)
                self.view.replace(edit, r, '(%s)' % s)
                new_sels.append(r.begin())

        set_selection(self.view, new_sels)
Example #2
0
    def run(self, edit):
        new_sels = []
        for s in self.view.sel():
            line = self.view.line(s.b)
            line_str = self.view.substr(line)
            m = match_around(r'[\w\.]+', line_str, s.b - line.begin())
            if m:
                r = sublime.Region(m[0] + line.begin(), m[1] + line.begin())
                if self.view.substr(r.end()) == '(':
                    closing = find_matching_paren(self.view, sublime.Region(r.end(), r.end()+1))
                    r = r.cover(closing)
                s = self.view.substr(r)
                self.view.replace(edit, r, '(%s)' % s)
                new_sels.append(r.begin())

        set_selection(self.view, new_sels)
Example #3
0
 def run(self, edit):
    blocks = [block_at(self.view, p) for p in list_cursors(self.view)]
    set_selection(self.view, blocks)