-
Notifications
You must be signed in to change notification settings - Fork 4
/
repeatMacro.py
26 lines (21 loc) · 1.03 KB
/
repeatMacro.py
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
#
# Sivakumar Kailasam and lowliet
#
import sublime, sublime_plugin
class RepeatMacroCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().show_input_panel("Repeat count or [Enter] to run till end of file", "", self.__execute, None, None)
def __execute(self, text):
if not text.isdigit() and len(text) > 0:
print("Repeat Macro | Wrong number")
# elif len(text) > 0 and int(text) > (self.__get_last_line() - self.__get_current_line()):
# print("Repeat Macro | Number too big (bigger than number of lines in file)")
else:
current_line = self.__get_current_line()
last_line = current_line + int(text) if len(text) > 0 else self.__get_last_line()
for i in range(current_line, last_line):
self.view.run_command("run_macro")
def __get_current_line(self):
return self.view.rowcol(self.view.sel()[0].begin())[0] + 1
def __get_last_line(self):
return self.view.rowcol(self.view.size())[0] + 2