-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasyWinPath.py
More file actions
29 lines (25 loc) · 971 Bytes
/
Copy patheasyWinPath.py
File metadata and controls
29 lines (25 loc) · 971 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
import sublime
import sublime_plugin
import subprocess
import os
class OpenCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
s = self.view.substr(region)
print("Will open {0}".format(s))
os.startfile(s)
if region.empty():
print("Region is empty")
class EscapeCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
s = self.view.substr(region)
if (s.startswith(r'\\\\') or ((not s.startswith(r'\\\\')) and (r'\\' in s) and (not s.startswith(r'\\')))):
s = s.replace('\\\\', "\\")
else:
s = s.replace('\\', "\\\\")
self.view.replace(edit, region, s)
if region.empty():
print("Region is empty")