def new_view(window, text, scratch=False):
 new_view = window.new_file()
 if scratch:
  new_view.set_scratch(True)
 if is_ST3():
  new_view.run_command('append', {'characters': text})
 else:
  new_edit = new_view.begin_edit()
  new_view.insert(new_edit, 0, text)
  new_view.end_edit(new_edit)
 return new_view

def new_view ( window , text , scratch = False ) : new_view = window . new_file ( ) if scratch : new_view . set_scratch ( True ) if is_ST3 ( ) : new_view . run_command ( 'append' , { 'characters' : text } ) else : new_edit = new_view . begin_edit ( ) new_view . insert ( new_edit , 0 , text ) new_view . end_edit ( new_edit ) return new_view
create a new view and paste text content return the new view .