Search code examples
sublimetext3sublimetext2sublimetextsublime-text-plugin

Switch view to a new file


I would like to open a new file and then replace this empty file with the strings from my list. Each list item on a separate line. I am using Sublime 3. Currently my plugin opens the new file, but does not change the view to the new file to edit (add the strings from my list).

I have the following code:

size = len(TheList)
count = 0
view = self.view.window().new_file()
allcontent = sublime.Region(0, self.view.size())
while size!=count:
    self.view.replace(edit, allcontent, TheList)
    count+=1

Solution

  • I need to use:

    self.view = self.view.window().new_file()