-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml.py
31 lines (26 loc) · 810 Bytes
/
html.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
27
28
29
30
31
import sublime, sublime_plugin
class State:
last_element_name = "div"
class WrapInDivCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().show_input_panel(
"Wrap in element named",
State.last_element_name,
self.on_done,
None,
None,
)
def on_done(self, name):
print "name", name
State.last_element_name = name
# self.view.run_command("upper_case")
edit = self.view.begin_edit()
try:
selected_ranges = self.view.sel()
for selection in selected_ranges:
# text = unicode(self.view.substr(selection), self.view.encoding())
text = self.view.substr(selection)
result = "<" + name + ">\n" + text + "\n</" + name + ">"
self.view.replace(edit, selection, result)
finally:
self.view.end_edit(edit)