Last active
August 8, 2025 02:13
-
-
Save hyrious/3f1b73279e011ff8aa7e92da2bd326de to your computer and use it in GitHub Desktop.
Copy diff without leading +
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 | |
import sublime_plugin | |
import re | |
class CopyDiffCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
chunks = [] | |
for region in self.view.sel(): | |
chunks.append(self.view.substr(region)) | |
text = '\n'.join(chunks) | |
text = re.sub(r"^[-+ ]", '', text, flags=re.M) | |
sublime.set_clipboard(text) | |
sublime.status_message('Copied ' + text) | |
def is_enabled(self): | |
return 'source.diff' in self.view.scope_name(0) |
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
Show hidden characters
[ | |
{ "keys": ["super+c"], "command": "copy_diff", "context": [{ "key": "selector", "operand": "source.diff", "operator": "equal", "match_all": true } ] } | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment