[code]import sublime, sublimeplugin, os, functools, shutil
class renameCurrentTab(sublimeplugin.WindowCommand):
def run(self, window, args):
view = window.activeView()
current_name = os.path.basename(view.fileName())
current_dir = os.path.dirname(view.fileName())
window.showInputPanel("New Tab Name:", current_name,
functools.partial(self.doRename, window, current_name, current_dir), None, None)
def doRename(self, window, current_name, current_dir, new_name):
old_name_path = os.path.join(current_dir, current_name)
new_name_path = os.path.join(current_dir, new_name)
os.rename(old_name_path, new_name_path)
window.runCommand('close')
window.openFile(new_name_path.replace('\\','/'))
class backupCurrentTab(sublimeplugin.WindowCommand):
backup_ext = “.bak” #file extension for backups
def run(self, window, args):
view = window.activeView()
backup_name_path = view.fileName() + self.backup_ext
shutil.copy(view.fileName(), backup_name_path)[/code]
NOTES: renameCurrentTab is same code as the other post I’m just posting everything for the sake of copy and paste ![:stuck_out_tongue: :stuck_out_tongue:](https://forum.sublimetext.com/images/emoji/twitter/stuck_out_tongue.png?v=9)
**renameCurrentTab **= renames the current tab and opens the newly renamed file.
**backupCurrentTab **= creates a backup file of the “current tab” by default does “.bak” extension, this can be changed to whatever you want. Like it was said before, this is basically a quick “Save As” with a predefined name that keeps old file open. Useful when you’re about to do “risky” or large changes to a file.
happy editing ![:smile: :smile:](https://forum.sublimetext.com/images/emoji/twitter/smile.png?v=9)