This sample is for changing file name and reopening the file with new name. The flow is as follows.
- A file (sample.py) is opened.
- Rename the file from sample.py to newsample.py.
- 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:
view.retarget(newname)