Created
March 14, 2013 12:45
-
-
Save shibainurou/5161033 to your computer and use it in GitHub Desktop.
String s = の行でペーストするとダブルクォーテーションをエスケープするプラグイン ref: http://qiita.com/items/68f966fe07540a6568d6
This file contains hidden or 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
class StringEscapePasteCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
line_str = self.view.substr(self.view.line(self.view.sel()[0])) | |
match = re.search('\".*\"', line_str) | |
if match: | |
sel_rowcol = self.view.rowcol(self.view.sel()[0].begin()) | |
if match.start() < sel_rowcol[1] and sel_rowcol[1] < match.end(): | |
clipboard = sublime.get_clipboard() | |
self.view.insert(edit, self.view.sel()[0].begin(), clipboard.replace('\"', '\\\"')) | |
else: | |
self.view.run_command('paste') | |
else: | |
self.view.run_command('paste') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment