Sublime Forum

[solved] How to capture the entire text as region?


I would like to override the entire text in the view.

What i have so far is half working:

class ExampleCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    content = 'Hello, World!'
    region = self.view.visible_region()
    self.view.replace(edit, region, content)

It doesn’t replace the entire text, it replaces only parts of it. What i am struggling with is to capture the entire file as a region:

# doesn't work
self.view.erase(edit, sublime.Region(0,-1))


solved my problem with:

self.view.replace(edit, sublime.Region(0,self.view.size()), content)