Changing File Name and Reopening Renamed File by Sublime Text

This sample is for changing file name and reopening the file with new name. The flow is as follows.

  1. A file ( is opened.
  2. Rename the file from to
  3. The opened file is replace to the file with new name.
os.rename(oldfilewithpath, newname)
view = self.view.window().find_open_file(oldfilewithpath)
if view: