Created
November 29, 2016 07:26
-
-
Save math2001/68ccd6077f52358c4b9d63d2f61181c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
def main(): | |
import os.path | |
import sublime | |
PATH_TO_REPLACE_COMMAND_FILE = os.path.join(sublime.packages_path(), 'replace_command.py') | |
if os.path.exists(PATH_TO_REPLACE_COMMAND_FILE): | |
return | |
code = """import sublime | |
import sublime_plugin | |
class ReplaceCommand(sublime_plugin.TextCommand): | |
def run(self, edit, region, text): | |
if len(region) != 2: | |
raise ValueError('ReplaceCommand: a region like should be a list with 2 items. Got {0}'.format(region)) | |
self.view.replace(edit, sublime.Region(region[0], region[1]), text)""" | |
with open(PATH_TO_REPLACE_COMMAND_FILE, 'w') as fp: | |
fp.write(code) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment