def run(self, edit): pos = cursor_pos(self.view) region = word_at(self.view, pos) if not region: return word = self.view.substr(region) all_regions = self.view.find_all(r'\b%s\b' % word) next_region = region_f(all_regions, region.end()) or first(all_regions) set_cursor(self.view, next_region.begin())
def run(self, edit): blocks = list_blocks(self.view) this_block = region_at(blocks, cursor_pos(self.view)) if not this_block: return next_block = region_f(blocks, this_block.end()) if not next_block: return swap_regions(self.view, edit, this_block, next_block) self.view.show(next_block)
def smart_down(region): target = region_f(regions, region.end()) or first(regions) return target.begin()