Created
August 29, 2011 15:27
-
-
Save jbjornson/1178622 to your computer and use it in GitHub Desktop.
Search for the text in the clipboard and cut the containing line to the clipboard
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
import sublime, sublime_plugin, re | |
# Search for the text in the clipboard and cut the containing line to the clipboard | |
# { "keys": ["alt+x"], "command": "slurp_line_using_clipboard" } | |
# https://gist.github.com/1178622 | |
class SlurpLineUsingClipboardCommand(sublime_plugin.TextCommand): | |
def run(self, edit, block=True): | |
search_string = re.escape(sublime.get_clipboard()) | |
region = self.view.find(search_string, 0, sublime.IGNORECASE) | |
if region: | |
# get the full line, copy it to the clipboard and then delete the line | |
region = self.view.full_line(region) | |
sublime.set_clipboard( self.view.substr(region)) | |
self.view.erase(edit, region) | |
else: | |
print 'Search string "%s" was not found' % (search_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment