Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

% should search forward on the line for a bracket to match

fixes #23
  • Loading branch information...
commit 2d11253512678dedad5db638d5af9087d65dc780 1 parent be07f0b
@misfo authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 vintage_motions.py
View
14 vintage_motions.py
@@ -1,3 +1,4 @@
+import re
import sublime, sublime_plugin
from vintage import transform_selection
from vintage import transform_selection_regions
@@ -126,13 +127,16 @@ def move_by_percent(self, percent):
def run(self, edit, repeat=1):
repeat = int(repeat)
if repeat == 1:
- bracket_chars = ")]}"
- def adj(pt):
- if (self.view.substr(pt) in bracket_chars):
- return pt + 1
+ re_brackets = re.compile(r"([(\[{])|([)}\])])")
+ def move_to_next_bracket(pt):
+ line = self.view.line(pt)
+ remaining_line = self.view.substr(sublime.Region(pt, line.b))
+ match = re_brackets.search(remaining_line)
+ if match:
+ return pt + match.start() + (1 if match.group(2) else 0)
else:
return pt
- transform_selection(self.view, adj)
+ transform_selection(self.view, move_to_next_bracket, extend=True)
self.view.run_command("move_to", {"to": "brackets", "extend": True, "force_outer": True})
else:
self.move_by_percent(repeat)
Please sign in to comment.
Something went wrong with that request. Please try again.