-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVoiceCode.py
More file actions
38 lines (28 loc) · 913 Bytes
/
VoiceCode.py
File metadata and controls
38 lines (28 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sublime, sublime_plugin
class SelectNextNumberCommand(sublime_plugin.TextCommand):
def run(self, edit):
pos = self.view.sel()[0].end()
region = self.view.find('(?:\d*\.)?\d+', pos)
if region.a == -1:
region.a = pos
region.b = pos
self.view.sel().clear()
self.view.sel().add(region)
class SelectNextWordCommand(sublime_plugin.TextCommand):
def run(self, edit):
pos = self.view.sel()[0].end()
region = self.view.find('\w+', pos)
if region.a == -1:
region.a = pos
region.b = pos
self.view.sel().clear()
self.view.sel().add(region)
class SelectPreviousWordCommand(sublime_plugin.TextCommand):
def run(self, edit):
pos = self.view.sel()[0].begin()
all_previous = [r for r in self.view.find_all('\w+') if r.begin() < pos]
if all_previous:
region = all_previous[-1] # return nearest
if region:
self.view.sel().clear()
self.view.sel().add(region)