Hi,
How do I get and modify (replace) the entire contents of a view?
Thanks in advance!
Hi,
How do I get and modify (replace) the entire contents of a view?
Thanks in advance!
Never mind, I got it. Here is is for anyone else that might be interested (assuming your’re using a WindowCommand):
[code]# get the current contents of the file
body = self.window.active_view().substr(sublime.Region(0, self.window.active_view().size()))
edit = self.window.active_view().begin_edit()
self.window.active_view().erase(edit, sublime.Region(0, self.window.active_view().size()))
self.window.active_view().insert(edit, 0, html)
self.window.active_view().end_edit(edit)[/code]