old_contents: import sublime, sublime_plugin
  
  class SumCommand(sublime_plugin.TextCommand):
    def run(self, edit):
      new_view = self.view.window().new_file()
      new_view.set_name('Sum')
      new_view.insert(edit, 0, '42')
      new_view.set_scratch(True)
  
new_contents: import sublime, sublime_plugin
  
  class SumCommand(sublime_plugin.TextCommand):
    def run(self, edit):
      new_view = self.view.window().new_file()
      new_view.set_name('Sum')
      new_view.insert(edit, 0, '42')
      new_view.set_read_only(True)
      new_view.set_scratch(True)
  
subject: Set new file to read-only