Skip to content

Instantly share code, notes, and snippets.

@shibainurou
Created March 14, 2013 12:45
Show Gist options
  • Save shibainurou/5161033 to your computer and use it in GitHub Desktop.
Save shibainurou/5161033 to your computer and use it in GitHub Desktop.
String s = の行でペーストするとダブルクォーテーションをエスケープするプラグイン ref: http://qiita.com/items/68f966fe07540a6568d6
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