-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_paste_buffer.py
32 lines (24 loc) · 952 Bytes
/
copy_paste_buffer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sublime
import sublime_plugin
class CopyEntireBufferCommand(sublime_plugin.TextCommand):
def description(self):
return 'Copy Entire Buffer'
def run(self, edit):
if self.view.settings().get('is_widget'):
return
region = sublime.Region(0, self.view.size())
text = self.view.substr(region)
sublime.set_clipboard(text)
class PasteEntireBufferCommand(sublime_plugin.TextCommand):
def description(self):
return 'Paste Entire Buffer'
def run(self, edit):
if self.view.settings().get('is_widget'):
return
text = sublime.get_clipboard()
if text:
selected_regions = tuple([region for region in self.view.sel()])
entire_buffer = sublime.Region(0, self.view.size())
self.view.replace(edit, entire_buffer, text)
self.view.sel().clear()
self.view.sel().add_all(selected_regions)